hey Guys
I am having issues with my code. Originally (see original code) I would loop through all sheets and combine data in to one. This worked great. Only 1 sheet had headers (data spill).
However, the sheet has now changed.
I would be really grateful for any help. I have seen copying rows that contain text and one where it was a value greater than 0 but i could get it to work in all sheets.
Thanks
I am having issues with my code. Originally (see original code) I would loop through all sheets and combine data in to one. This worked great. Only 1 sheet had headers (data spill).
VBA Code:
'Original code
For i = 2 To Sheets.Count
Set xRg = Sheets(1).UsedRange
If i > 2 Then
Set xRg = Sheets(1).Cells(xRg.Rows.Count + 1, 1)
End If
Sheets(i).Activate
ActiveSheet.UsedRange.Copy xRg
Next
However, the sheet has now changed.
- There are now headers in all the sheets
- The headers are over two rows with merged cells
- There are now more sheets added (some hidden)
- Only values in a new column multiplying E:F =>10 need to be added to the combined sheet
- I have set all unwanted sheets to very hidden so that they remain out the way e.g:
VBA Code:
ActiveWorkbook.Sheets("CI").Visible = xlVeryHidden
- I then created the combined sheet and copied and pasted the two header rows from one of the data sheets.
- I then looped through the remaining worksheets and added a formula in columns S to give us the new values to filter on. Because of the merged cells, I just set a range (although id rather it used last row (I couldn't get this to work form A6, due to the merged cells, see code below)
- I now want to loop back through all sheets (excl combined sheet) and .copyentirerow on anything =>10 in col S and no matter what I haver tried I cant get it to work.
VBA Code:
'Apply Formula to all sheets
For Each wSht In Worksheets
If wSht.Name <> "Combined" Then
wSht.Range("S6:S200").Formula = "=RC[-14]*RC[-13]"
End If
Next wSht
'i tried to filter it when I couldn't look for the value, but this doesn't work
For Each xWs In Worksheets
If xWs.Name <> "Combined" Then
xWs.Range("S1").AutoFilter 1, "=>12"
End If
Next xWs
I would be really grateful for any help. I have seen copying rows that contain text and one where it was a value greater than 0 but i could get it to work in all sheets.
Thanks