Skip to main content

VBA Coding - For Making Consolidated Data sheet by using MultipleSheets data (MultipleSheets डेटा का उपयोग करके समेकित डाटा बनाने के लिए)

VBA Coding - For Making Consolidated Data sheet by using MultipleSheets data
 (MultipleSheets डेटा का उपयोग करके समेकित डाटा बनाने के लिए)



Sub For_Mastersheet_Update()

Dim wb As Workbook
Dim rng As Range


Set wb = Workbooks("Pk_File.xlsm")

wb.Activate

Worksheets("Master").Activate
Worksheets("Master").Cells.ClearContents

Worksheets("XYZ2").Activate

Worksheets("XYZ2").Range("a1").CurrentRegion.Select  ' For Select Current Region or All Data
Worksheets("XYZ2").Range("a1").CurrentRegion.Copy    ' For Copy Select Data
Worksheets("Master").Activate                        ' For activate sheet where you want to copy data
Worksheets("Master").Range("a1").PasteSpecial Paste:=xlPasteValuesAndNumberFormats  ' Paste Copy Data
Selection.Columns.AutoFit                            ' For Selected Columns Auto Fit

'For Next Sheet Active,Select,Copy & Active Master sheet With go to End Down Cell command & down one cell more and Paste & Autofit

Worksheets("XYZ1").Activate

Worksheets("XYZ1").Range("a2").CurrentRegion.Select  ' For Select Current Region or All Data
Worksheets("XYZ1").Range("a2").CurrentRegion.Copy

Worksheets("Master").Activate

With wb.Worksheets("Master").Range("a1").End(xlDown).Select                 ' For go to END Down cell
ActiveCell.Offset(1, 0).PasteSpecial Paste:=xlPasteValuesAndNumberFormats   ' Down One Cell and PasteValue with Number Format
Selection.Columns.AutoFit

End With

'For Next Sheet Active,Select,Copy & Active Master sheet With go to End Down Cell command & down one cell more and Paste & Autofit

Worksheets("XYZ7").Activate

Worksheets("XYZ7").Range("a2").CurrentRegion.Select  ' For Select Current Region or All Data
Worksheets("XYZ7").Range("a2").CurrentRegion.Copy

Worksheets("Master").Activate

With wb.Worksheets("Master").Range("a1").End(xlDown).Select                 ' For go to END Down cell
ActiveCell.Offset(1, 0).PasteSpecial Paste:=xlPasteValuesAndNumberFormats   ' Down One Cell and PasteValue with Number Format
Selection.Columns.AutoFit

End With

'For Next Sheet Active,Select,Copy & Active Master sheet With go to End Down Cell command & down one cell more and Paste & Autofit

Worksheets("XYZ4").Activate

Worksheets("XYZ4").Range("a2").CurrentRegion.Select  ' For Select Current Region or All Data
Worksheets("XYZ4").Range("a2").CurrentRegion.Copy

Worksheets("Master").Activate

With wb.Worksheets("Master").Range("a1").End(xlDown).Select                 ' For go to END Down cell
ActiveCell.Offset(1, 0).PasteSpecial Paste:=xlPasteValuesAndNumberFormats   ' Down One Cell and PasteValue with Number Format
Selection.Columns.AutoFit

End With

'For Next Sheet Active,Select,Copy & Active Master sheet With go to End Down Cell command & down one cell more and Paste & Autofit

Worksheets("XYZ3").Activate

Worksheets("XYZ3").Range("a2").CurrentRegion.Select  ' For Select Current Region or All Data
Worksheets("XYZ3").Range("a2").CurrentRegion.Copy

Worksheets("Master").Activate

With wb.Worksheets("Master").Range("a1").End(xlDown).Select                 ' For go to END Down cell
ActiveCell.Offset(1, 0).PasteSpecial Paste:=xlPasteValuesAndNumberFormats   ' Down One Cell and PasteValue with Number Format
Selection.Columns.AutoFit

End With

'For Next Sheet Active,Select,Copy & Active Master sheet With go to End Down Cell command & down one cell more and Paste & Autofit

Worksheets("XYZ6").Activate

Worksheets("XYZ6").Range("a2").CurrentRegion.Select  ' For Select Current Region or All Data
Worksheets("XYZ6").Range("a2").CurrentRegion.Copy

Worksheets("Master").Activate

With wb.Worksheets("Master").Range("a1").End(xlDown).Select                 ' For go to END Down cell
ActiveCell.Offset(1, 0).PasteSpecial Paste:=xlPasteValuesAndNumberFormats   ' Down One Cell and PasteValue with Number Format
Selection.Columns.AutoFit

End With

'For Next Sheet Active,Select,Copy & Active Master sheet With go to End Down Cell command & down one cell more and Paste & Autofit

Worksheets("XYZ9").Activate

Worksheets("XYZ9").Range("a2").CurrentRegion.Select  ' For Select Current Region or All Data
Worksheets("XYZ9").Range("a2").CurrentRegion.Copy

Worksheets("Master").Activate

With wb.Worksheets("Master").Range("a1").End(xlDown).Select                 ' For go to END Down cell
ActiveCell.Offset(1, 0).PasteSpecial Paste:=xlPasteValuesAndNumberFormats   ' Down One Cell and PasteValue with Number Format
Selection.Columns.AutoFit

End With

'For Next Sheet Active,Select,Copy & Active Master sheet With go to End Down Cell command & down one cell more and Paste & Autofit

Worksheets("XYZ5").Activate

Worksheets("XYZ5").Range("a2").CurrentRegion.Select  ' For Select Current Region or All Data
Worksheets("XYZ5").Range("a2").CurrentRegion.Copy

Worksheets("Master").Activate

With wb.Worksheets("Master").Range("a1").End(xlDown).Select                 ' For go to END Down cell
ActiveCell.Offset(1, 0).PasteSpecial Paste:=xlPasteValuesAndNumberFormats   ' Down One Cell and PasteValue with Number Format
Selection.Columns.AutoFit

End With

'For Next Sheet Active,Select,Copy & Active Master sheet With go to End Down Cell command & down one cell more and Paste & Autofit

Worksheets("XYZ8").Activate

Worksheets("XYZ8").Range("a2").CurrentRegion.Select  ' For Select Current Region or All Data
Worksheets("XYZ8").Range("a2").CurrentRegion.Copy

Worksheets("Master").Activate

With wb.Worksheets("Master").Range("a1").End(xlDown).Select                 ' For go to END Down cell
ActiveCell.Offset(1, 0).PasteSpecial Paste:=xlPasteValuesAndNumberFormats   ' Down One Cell and PasteValue with Number Format
Selection.Columns.AutoFit

End With

'For Next Sheet Active,Select,Copy & Active Master sheet With go to End Down Cell command & down one cell more and Paste & Autofit

Worksheets("XYZ8").Activate

Worksheets("XYZ8").Range("a2").CurrentRegion.Select  ' For Select Current Region or All Data
Worksheets("XYZ8").Range("a2").CurrentRegion.Copy

Worksheets("Master").Activate

With wb.Worksheets("Master").Range("a1").End(xlDown).Select                 ' For go to END Down cell
ActiveCell.Offset(1, 0).PasteSpecial Paste:=xlPasteValuesAndNumberFormats   ' Down One Cell and PasteValue with Number Format
Selection.Columns.AutoFit

End With

'For Next Sheet Active,Select,Copy & Active Master sheet With go to End Down Cell command & down one cell more and Paste & Autofit

Worksheets("XYZ").Activate

Worksheets("XYZ").Range("a2").CurrentRegion.Select  ' For Select Current Region or All Data
Worksheets("XYZ").Range("a2").CurrentRegion.Copy

Worksheets("Master").Activate

With wb.Worksheets("Master").Range("a1").End(xlDown).Select                 ' For go to END Down cell
ActiveCell.Offset(1, 0).PasteSpecial Paste:=xlPasteValuesAndNumberFormats   ' Down One Cell and PasteValue with Number Format
Selection.Columns.AutoFit

End With

'For Next Sheet Active,Select,Copy & Active Master sheet With go to End Down Cell command & down one cell more and Paste & Autofit

Worksheets("XYZ12").Activate

Worksheets("XYZ12").Range("a2").CurrentRegion.Select  ' For Select Current Region or All Data
Worksheets("XYZ12").Range("a2").CurrentRegion.Copy

Worksheets("Master").Activate

With wb.Worksheets("Master").Range("a1").End(xlDown).Select                 ' For go to END Down cell
ActiveCell.Offset(1, 0).PasteSpecial Paste:=xlPasteValuesAndNumberFormats   ' Down One Cell and PasteValue with Number Format
Selection.Columns.AutoFit

End With

'For Next Sheet Active,Select,Copy & Active Master sheet With go to End Down Cell command & down one cell more and Paste & Autofit

Worksheets("XYZ11").Activate

Worksheets("XYZ11").Range("a2").CurrentRegion.Select  ' For Select Current Region or All Data
Worksheets("XYZ11").Range("a2").CurrentRegion.Copy

Worksheets("Master").Activate

With wb.Worksheets("Master").Range("a1").End(xlDown).Select                 ' For go to END Down cell
ActiveCell.Offset(1, 0).PasteSpecial Paste:=xlPasteValuesAndNumberFormats   ' Down One Cell and PasteValue with Number Format
Selection.Columns.AutoFit

End With


'For Delete Filter Rows except Heading

With Worksheets("Master").Range("a2:p500")
.AutoFilter field:=1, Criteria1:="Date"
.EntireRow.Delete

Worksheets("Master").Range("a1").CurrentRegion.Select  ' For Select Current Region or All Data
Selection.Columns.AutoFit                              ' For Columns Auto Fit

' Table Creation for current selection

Dim tbl As ListObject
Set tbl = ActiveSheet.ListObjects.Add(xlSrcRange, Selection, xlYes)
tbl.Name = "Master"


End With


End Sub


Comments

Popular posts from this blog

Excel Simple Formulas एक्सेल सरल सूत्र

Excel uses Standard Operators for formulas, such as a Plus Sign (+) for Addition , a Minus Sign (-) for Subtraction , an Asterisk Sign (*) for Multiplication , a Forward Slash Sign (/) for Division , and a Caret Sign (^) for Exponents . All these are Mathematical Operators and in Excel All Formulas must begin with an Equals Sign (=). एक्सेल सूत्रों के लिए मानक ऑपरेटर का उपयोग करता है, जैसे अतिरिक्त के लिए प्लस साइन (+), घटाव के लिए एक ऋण चिह्न (-), गुणा के लिए एक तारांकन चिह्न (*), प्रभाग के लिए एक फॉरवर्ड स्लैश साइन (/), और एक कैरेट साइन (^) एक्सपोनेंट्स के लिए। ये सभी गणितीय ऑपरेटर हैं और एक्सेल में सभी सूत्रों को बराबर चिह्न (=) से शुरू होना चाहिए। Addition + Subtraction - Multiplication * Division / Exponents ^ For example  :-

VBA Coding For Login Form लॉगिन फॉर्म के लिए VBA कोडिंग

VBA Coding For Login Form Need  TextBox Name = txtUserName TextBox Name = txtPassword Button Name = cmdSubmit Button Name = cmdClear Button Name = cmdExit & One Excel Sheet which have User ID & Password ----------------------------------------------------------------------- Private Sub cmdClear_Click() txtUserName.Value = "" txtPassword.Value = "" End Sub -------------------------------------------------------------------------- Private Sub cmdExit_Click() ActiveWorkbook.Close savechanges = True End End Sub ---------------------------------------------------------------------------- Private Sub cmdSubmit_Click() Worksheets("User").Range("A1").Value = txtUserName.Value Worksheets("User").Range("A2").Value = txtPassword.Value If (Worksheets("User").Range("C1").Value = True) And Worksheets("User").Range("C2").Value = True Then     MsgBo...

Excel VBA Code For Clear Cell एक्सेल VBA कोड क्लियर सेल के लिए

# VBA Code to Clear Cell :- To  clear cells using VBA , use a statement with the following structure:- VBA का उपयोग :-  सेल  को साफ करने के लिए Cells.Clear VBA Statement Explanation Item:  Cells. VBA Construct:  Range object. Description:  Range object representing the cells you want to clear. You can usually return a Range object with constructs such as the Worksheet.Range, Worksheet.Cells (with Range.Item), Range.Offset, Range.Resize or Application.ActiveCell properties. If you explicitly declare an object variable to represent Cells, use the Range object data type. Item:  Clear. VBA Construct:  Range.Clear method. Description:  The Range.Clear method clears the Range object you specify (Cells). Range.Clear clears the entire Range object, including values, formulas and formatting. VBA स्टेटमेंट स्पष्टीकरण 1. आइटम: सेल। VBA निर्माण: रेंज ऑब्जेक्ट। विवरण: रेंज ऑब्जेक्ट उन कोश...