Hi,
I am trying to copy rows from one sheet to another if the value in a cell contains a substring like "apple". Some comments below contain questions because I am unsure how to do it. There is probably a better more efficient way to do this.
Eileen
I am trying to copy rows from one sheet to another if the value in a cell contains a substring like "apple". Some comments below contain questions because I am unsure how to do it. There is probably a better more efficient way to do this.
Eileen
Code:
Rw = Range("A65536").End(xlUp).Row
Counter1 = 9 ' this is where I want to start checking
Counter2 = 9 ' keeps track of row in new sheet
Do Until Counter1 > Rw
' I am checking the value in column 5 of the current row
' check it the string contains "apple" (not sure what to use for substring comparison)
If Cells(Counter1, 5) contains "apple" Then
Rows("Counter1:Counter1").Select
Selection.Copy
' not sure how to use a variable inside of a cell reference.
' if Counter 2 is 5, then I want the below to select the row
' associated with A5
Range("A{Counter2}").Select
' if new sheet does not exist, create it
' not sure what check is used to see if a sheet exists
Sheets("New Sheet").Select
ActiveSheet.Paste
Counter2 = Counter2 + 1
' not sure if I have to keeping selecting sheets back and forth
' when I am copying and pasting
Sheets("name of sheet which script is copying from").Select
end if
Counter = Counter + 1
Loop