I have a spreadsheet with rows of data where I want to copy only the rows where the sample name begins with S or s. The following code does this but copies each “S” or “s” row on top of the previously copied data instead of locating the first open row. Important for you to know that there is no data in Column A so all the copied rows go into row 2. I realized this and when I change the column “A” to “B” where I have some header data which should permit the macro to determine the proper open row to put the data, , the macro crashes saying there is a copy/paste size mismatch (Runtime error 1004). I have worked and experimented and googled on this for several hours and would appreciate any help!
Thanks
Arjay
Sub CopyStandardsRows()
Dim Oldsheet As String
Dim newstring As String
‘use to copy all rows with Standards to New worksheet
‘add a sheet named “Standards” & return to the original sheet
‘
Oldsheet$ = ActiveSheet.Name
Worksheets.Add(After:=Worksheets(Worksheets.Count)).Name = “Standards”
Range(“D1”).Activate
Worksheets(Oldsheet$).Activate
‘Copy rows (“2:4”) to “Standards” sheet
Rows(“2:4”).Copy Destination:=Sheets(“Standards”).Rows(“2:4”)
Range(“C5”).Activate
Do While Not IsEmpty(ActiveCell)
newstring = Left(ActiveCell.Value, 1)
If newstring = “S” Or newstring = “s” Then
ActiveCell.EntireRow.Copy Destination:=Sheets(“Standards”).Range _
(“a” & Rows.Count).End(xlUp).Offset(1)
End If
ActiveCell.Offset(1, 0).Select
Loop
End Sub