PhilThomas
New Member
- Joined
- Jul 5, 2004
- Messages
- 21
Hi,
I've been at this for 3 hours and its not going in. I've searched the board and google and have come up with various answers I've tried to adapt but I just can't get it to work.
Goal - To have a mastersheet built from a set of 12 named sheets (there are 20 named sheets in the workbook altogether). However only from a certain collection of rows and also ensuring that the header row is only copied over once.
So using
Sub copySheets()
Dim sh As Worksheet
Sheets("Master").Select
ActiveSheet.Cells.Clear
Dim i As Integer
i = 1
For Each sh In ThisWorkbook.Sheets
If (sh.Name = "A") Or (sh.Name = "V") Or (sh.Name = "NP") Or (sh.Name = "N") Then
sh.UsedRange.Copy
Range("A" & Rows.Count).End(xlUp).Offset(1 - i, 0).Select
ActiveSheet.Paste
i = 0
End If
Next sh
End Sub
Clears the Master sheet, checks only for the named sheets, but copies everything from the named sheets. Each sheet typically holds data from Col A to Col J and upto 30 rows.
I am only interested in the rows which have data in col F which can be anything.
I simply want to select and clear a sheet called Master. Take the headings from the first named sheet (as they are the same across all the sheets). Copy all of the entire rows which have an entry in Col F into the Master sheet. Move to the next named sheet. Ignore the header row (which always starts at a1) and copy all the information from the rows which have a value in col F and paste it into the Master sheet. Repeat for all named sheets.
I've tried messing around with a range select for the named sheet with a sh.range but keep getting error 1004 and its driving me mad.
any help much appreciated
Phil
I've been at this for 3 hours and its not going in. I've searched the board and google and have come up with various answers I've tried to adapt but I just can't get it to work.
Goal - To have a mastersheet built from a set of 12 named sheets (there are 20 named sheets in the workbook altogether). However only from a certain collection of rows and also ensuring that the header row is only copied over once.
So using
Sub copySheets()
Dim sh As Worksheet
Sheets("Master").Select
ActiveSheet.Cells.Clear
Dim i As Integer
i = 1
For Each sh In ThisWorkbook.Sheets
If (sh.Name = "A") Or (sh.Name = "V") Or (sh.Name = "NP") Or (sh.Name = "N") Then
sh.UsedRange.Copy
Range("A" & Rows.Count).End(xlUp).Offset(1 - i, 0).Select
ActiveSheet.Paste
i = 0
End If
Next sh
End Sub
Clears the Master sheet, checks only for the named sheets, but copies everything from the named sheets. Each sheet typically holds data from Col A to Col J and upto 30 rows.
I am only interested in the rows which have data in col F which can be anything.
I simply want to select and clear a sheet called Master. Take the headings from the first named sheet (as they are the same across all the sheets). Copy all of the entire rows which have an entry in Col F into the Master sheet. Move to the next named sheet. Ignore the header row (which always starts at a1) and copy all the information from the rows which have a value in col F and paste it into the Master sheet. Repeat for all named sheets.
I've tried messing around with a range select for the named sheet with a sh.range but keep getting error 1004 and its driving me mad.
any help much appreciated
Phil
Last edited: