Hi,
I have written a data extraction code here. The Cells.Find value will be taken from Cell A2, A3, A4... down. I have put "For x = 2 to 88" but data set is not 88 rows long and i do not wish to change it everytime i change row numbers. What i want to do, is that when a blank cell (Ax) is reached, i want the code to jump to the Red colored code. How would i do this? I've tried If FindValue = "" GoTo ... but i keep getting errors
Thanks!
p.s. this is my first time writing such a long code and I've learnt this for a week so it'll probably look messy and junky to you.
Sub DataExtraction()
Sheets("Sheet2").Select
Range("A1").Activate
For x = 2 To 88
FindValue = Sheets("Sheet3").Cells(x, 1).Value
Sheets("Sheet2").Select
Cells.Find(What:=FindValue, after:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
ActiveCell.Offset(0, -3).Select
If IsEmpty(ActiveCell) Then
Cells.FindNext(after:=ActiveCell).Activate
Cells.FindNext(after:=ActiveCell).Activate
ActiveCell.Offset(0, -3).Select
Selection.Copy
ActiveSheet.Next.Select
Cells(x, 2).Select
ActiveSheet.Paste
Else
Cells.FindNext(after:=ActiveCell).Activate
Cells.FindNext(after:=ActiveCell).Activate
ActiveCell.Offset(0, -3).Select
Selection.Copy
ActiveSheet.Next.Select
Cells(x, 2).Select
ActiveSheet.Paste
End If
Next x
Sheets("sheet2").Select
Range("A1").Activate
For x = 2 To 88
FindValue = Sheets("sheet3").Cells(x, 1).Value
Sheets("sheet2").Select
Cells.Find(What:=FindValue, after:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
ActiveCell.Offset(0, 15).Select
If IsEmpty(ActiveCell) Then
Cells.FindNext(after:=ActiveCell).Activate
ActiveCell.Offset(0, 15).Select
Selection.Copy
ActiveSheet.Next.Select
Cells(x, 3).Select
ActiveSheet.Paste
Else
Selection.Copy
ActiveSheet.Next.Select
Cells(x, 3).Select
ActiveSheet.Paste
End If
Next x
End Sub
Bookmarks