-
Combining selected work sheets into one
Hi,
I took the help of the macro written by Lucas to combine mulitple work sheets.
Is there way to select only few of the work sheets and create a master instead of all the worksheets?
If yes please let me know how to do it.
The URL from which I took the macro is given below
http://www.vbaexpress.com/forum/show...035#post104035
Thanks a lot for all your time.
-
Change the 2nd part of the code with this (not tried) : [VBA] 'We can start loop
For Each sht In wrk.Worksheets
'If worksheet in loop is the last one, stop execution (it is Master worksheet)
If sht.Index = wrk.Worksheets.Count Then
Exit For
End If
If Worksheets(sht.Index).Name = "Name one" Or _
Worksheets(sht.Index).Name = "Name two" Then
'Data range in worksheet - starts from second row as first rows are the header rows in all worksheets
Set rng = sht.Range(sht.Cells(2, 1), sht.Cells(65536, 1).End(xlUp).Resize(, colCount))
'Put data into the Master worksheet
trg.Cells(65536, 1).End(xlUp).Offset(1).Resize(rng.Rows.Count, rng.Columns.Count).Value = rng.Value
End If
Next sht
'Fit the columns in Master worksheet
trg.Columns.AutoFit
'Screen updating should be activated
Application.ScreenUpdating = True[/VBA]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules