PizzaBoxWings
New Member
- Joined
- May 17, 2022
- Messages
- 5
- Office Version
- 365
- Platform
- Windows
Hello, I have looked through quite a few posts already and some of the code provided is a little funky and I cannot quite figure out how to adjust it to suit what I need.
I have a worksheet "sheet5" with data subtotaled. I want to copy only rows which contain either "3" or "3 total" in column C and have it paste the data into "Sheet6" with out rows and rows of spaces between the data. there are over 2000 rows and probably only 500 contain the specific criteria for the transfer.
at the moment this is the code I am using. The data containing "3" in column C is transferring over but i cannot get the rows which contain "3 total" in column C to also make their way to the new sheet. there are also many, many rows between each transferred set of data.
thanks again in advance and sorry if i am not very clear i am still very new to this forum and to VBAs
I have a worksheet "sheet5" with data subtotaled. I want to copy only rows which contain either "3" or "3 total" in column C and have it paste the data into "Sheet6" with out rows and rows of spaces between the data. there are over 2000 rows and probably only 500 contain the specific criteria for the transfer.
at the moment this is the code I am using. The data containing "3" in column C is transferring over but i cannot get the rows which contain "3 total" in column C to also make their way to the new sheet. there are also many, many rows between each transferred set of data.
thanks again in advance and sorry if i am not very clear i am still very new to this forum and to VBAs
VBA Code:
Sub transfer_only_march_data()
Dim wsO As Worksheet, wsE As Worksheet
Dim LR As Long, i As Long
Set wsO = Sheets("sheet5")
Set wsE = Sheets("sheet6")
LR = wsO.Cells(Rows.Count, 1).End(xlUp).Row
With wsE
For i = 2 To .Cells(Rows.Count, 3).End(xlUp).Row
If .Cells(i, 3).Valuecontains = "3" Then
.Rows(i).Copy wsO.Rows(LR + 1)
LR = LR + 1
End If
Next
End With
End Sub