excel-a-macro-for-copying-data-from-different-sheets-10517-lu3hzc.pdf
-
Upload
daniel-shelton -
Category
Documents
-
view
214 -
download
0
Transcript of excel-a-macro-for-copying-data-from-different-sheets-10517-lu3hzc.pdf
-
7/21/2019 excel-a-macro-for-copying-data-from-different-sheets-10517-lu3hzc.pdf
1/2
Excel - a Macro for copying data from
different sheets
June 2014
[Excel] a Macro for copying data from
different sheetsIssue
Solution
Note that
Issue
I am trying to copy data from different sheets to master sheet under the following
criteria
Master sheet should be generated whenever I run a macro erasing the previous master
sheet.
All the Column headings are identical.
For master sheet only one heading should be copied (i.e. first row should not be copied
from the second sheet.)If zero values in a particular cell are appearing then that row should not be copied.
Master sheet should be sorted as per the column i mention in running the macro. (I.e. I will
assign on the message box the field/column that should be sorted in the master sheet.)
Solution
I have one doubt you want to copy data for all the months to master sheet OR for month by month.
I assumed all the months. In that case try this macro
http://localhost/var/www/apps/conversion/tmp/scratch_5/http://localhost/var/www/apps/conversion/tmp/scratch_5/ -
7/21/2019 excel-a-macro-for-copying-data-from-different-sheets-10517-lu3hzc.pdf
2/2
Sub test()
Dim j As Long, k As Long, r As Range
j = Worksheets.Count
With Worksheets("master")
Set r = Range(.Range("A2"), .Range("A2").End(xlDown))
r.EntireRow.Delete
End With
For k = 1 To j
If Worksheets(k).Name = "master" Then GoTo errorhandler
With Worksheets(k)
If .Range("A2") = "" Then GoTo errorhandler
Set r = Range(.Range("A2"), .Range("A2").End(xlDown))
r.EntireRow.Copy
Worksheets("master").Cells(Rows.Count, "A").End(xlUp).Offset(1, 0).PasteSpecial
End With
errorhandler:Next k
End Sub
In your file you have too many empty modules. Remove all of them except module1.
Note that
Solved by venkat1926This document entitled Excel - a Macro for copying data from different sheets from Kioskea (en.kioskea.net) is
made available under the Creative Commons license. You can copy, modify copies of this page, under the conditions
stipulated by the license, as this note appears clearly.
http://localhost/var/www/apps/conversion/tmp/scratch_5/ccmguide/ccmlicence.php3http://en.kioskea.net/http://en.kioskea.net/http://en.kioskea.net/faq/10517-excel-a-macro-for-copying-data-from-different-sheets