0

I have managed to make it this far with my macro, but I cant figure out how to loop the macro to the next line. Any assistance would be greatly appreciated.

Here is the macro that I need looped:

Sub loopplannercomments()
'
' loopplannercomments Macro
' gather planner comments for each line
'


    Range("I31").Select
    Selection.Copy
    Windows("BP Tool Notes for Missing Material 12.27.xlsm").Activate
    ActiveSheet.PivotTables("PivotTable1").PivotFields("sod_part").ClearAllFilters
    ActiveSheet.PivotTables("PivotTable1").PivotFields("sod_part").CurrentPage = _
        "S166877 / 2"
    Range("F10").Select
    Selection.Copy
    Range("G10").Select
    Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
        xlNone, SkipBlanks:=False, Transpose:=False
    Range("G10").Select
    ActiveCell.Replace What:="(  )", Replacement:="", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
    
    Range("g15").Select
    Selection.Copy
    Range("H15").Select
    Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
        xlNone, SkipBlanks:=False, Transpose:=False
    Range("h15").Select
    Application.CutCopyMode = False
    Selection.Copy
    Windows("SPV Schedule 1.13 LACERENZA REV1.xlsm").Activate
    Range("O31").Select
    ActiveSheet.Paste
End Sub

I have tried researching what different types of loop structures there are, and I am not sure which one I should use or how to implement said code string.

Scott Craner
  • 148,073
  • 10
  • 49
  • 81
  • 2
    You might benefit from reading [How to avoid using Select in Excel VBA](https://stackoverflow.com/questions/10714251/how-to-avoid-using-select-in-excel-vba). – Pᴇʜ Jan 17 '23 at 16:28
  • 4
    There are a bunch of different ranges there - it's not clear *exactly* what you mean by "next line" - next *to what*? – Tim Williams Jan 17 '23 at 16:49
  • There`s a bunch of questions on this site about finding the last row in a range – cybernetic.nomad Jan 17 '23 at 19:31
  • https://stackoverflow.com/questions/51196975/building-a-do-until-loop-to-loop-a-column-until-empty-cell – Maya Jan 18 '23 at 06:11
  • The old ones are the best, start simple with a `For ... Next` loop and take it from there. https://learn.microsoft.com/en-us/office/vba/language/reference/user-interface-help/fornext-statement – user10186832 Jan 18 '23 at 08:14

0 Answers0