Knockoutpie
Board Regular
- Joined
- Sep 10, 2018
- Messages
- 116
- Office Version
- 365
- Platform
- Windows
Hi everyone, done quite a bit of research and I cannot quite figure this out..
This script should be
* searching for "PartNum" once found
* moves down 2 cells
* Copies the value on the new active cell
* searches for that value in worksheet "export"
* once found copies the value offset 24 cells to the right
* returns to workbook "quote"
* Finds "Leadtime"
* move down 2 cells and pastes the value
The part i'm stuck on, I didn't write this correctly to loop as i would like, how can i accurately loop 1 row lower each time? Is there any way I can add so it ignores if a part is not found instead of erroring out?
This script should be
* searching for "PartNum" once found
* moves down 2 cells
* Copies the value on the new active cell
* searches for that value in worksheet "export"
* once found copies the value offset 24 cells to the right
* returns to workbook "quote"
* Finds "Leadtime"
* move down 2 cells and pastes the value
The part i'm stuck on, I didn't write this correctly to loop as i would like, how can i accurately loop 1 row lower each time? Is there any way I can add so it ignores if a part is not found instead of erroring out?
VBA Code:
'Find PartNum
Worksheets("Quote").Activate
Cells.Find(What:="PartNum").Offset(2, 0).Select
'Copy/search part Num
Dim str1 As String
Dim Cntr As Integer
Cntr = 0
Do While Cntr <= 650
Cntr = Cntr + 1
str1 = ActiveCell.Value
Selection.Copy
Worksheets("Export").Activate
ActiveCell.Select
Cells.Find(What:=str1, After:=ActiveCell, LookIn:= _
xlFormulas, lookat:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _
xlNext, MatchCase:=False, SearchFormat:=False).Activate
Cells.FindNext(After:=ActiveCell).Activate
ActiveCell.Offset(0, 24).Range("A1").Select
Selection.Copy
Worksheets("Quote").Activate
'Find PartNum
Cells.Find(What:="Leadtime").Offset(2, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues
Loop
Last edited: