The code below works fine and does exactly what i want it to do, however what is the best way to loop it
Sheet "New" has approx 3000 lines of data, the code below finds the first instance of SC which in this argument is 999, after its copied those values to "Database" how can i get it to continue searching through the rest of the lines on "New"
Any guidance would be appreciated
Sheet "New" has approx 3000 lines of data, the code below finds the first instance of SC which in this argument is 999, after its copied those values to "Database" how can i get it to continue searching through the rest of the lines on "New"
Code:
Sheets(1).Copy After:=Workbooks(workbookname).Sheets("Database")
Sheets(3).Name = ("New")
LastrowD = Sheets("Database").Cells(Rows.Count, "J").End(xlUp).Row + 1
lastrowN = Sheets("New").Cells(Rows.Count, "C").End(xlUp).Row
lastrowb = Sheets("New").Cells(Rows.Count, "A").End(xlUp).Row
ThisWorkbook.ActiveSheet.Cells.ClearFormats
ThisWorkbook.ActiveSheet.Cells.HorizontalAlignment = xlLeft
Lastrowa = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row
Workbooks(acname).Activate
ActiveWorkbook.Close SaveChanges:=False
SC = Sheets("Admin").Cells(2, 3)
SearchString = SC
Debug.Print SC
Set SearchRange = Sheets("New").Range("C7:C" & lastrowN).Find(SearchString)
If SearchRange Is Nothing Then
Debug.Print "cant find any data"
Else
Sheets("Database").Range("A" & LastrowD).Value = SearchRange.Offset(, -2).Value
Sheets("Database").Range("B" & LastrowD).Value = SearchRange.Offset(, -1).Value
Sheets("Database").Range("C" & LastrowD).Value = SearchRange.Offset(, 0).Value
Sheets("Database").Range("D" & LastrowD).Value = SearchRange.Offset(, 1).Value
Sheets("Database").Range("E" & LastrowD).Value = SearchRange.Offset(, 2).Value
Sheets("Database").Range("F" & LastrowD).Value = SearchRange.Offset(, 3).Value
Sheets("Database").Range("G" & LastrowD).Value = SearchRange.Offset(, 4).Value
Sheets("Database").Range("H" & LastrowD).Value = SearchRange.Offset(, 5).Value
Sheets("Database").Range("I" & LastrowD).Value = SearchRange.Offset(, 6).Value
Sheets("Database").Range("J" & LastrowD).Value = SearchRange.Offset(, 7).Value
Sheets("Database").Range("K" & LastrowD).Value = SearchRange.Offset(, 8).Value
Sheets("Database").Range("L" & LastrowD).Value = SearchRange.Offset(, 9).Value
Sheets("Database").Range("M" & LastrowD).Value = SearchRange.Offset(, 10).Value
Sheets("Database").Range("N" & LastrowD).Value = SearchRange.Offset(, 11).Value
Sheets("Database").Range("O" & LastrowD).Value = SearchRange.Offset(, 12).Value
End If
Any guidance would be appreciated