.....on a separate workbook indefinitely.
Hello First off I am new here and very new to VBA. I have a workbook that has a list that will grow indefinitely named "book1" and the code i pieced together grabs data from a range in that book and pastes it into another book "DMAutocalcs"in one specific row one at a time and the the code executes a refresh and wait time, after which it copy certain pricing date from a specific range in "DMautoCalcs" back into Book1. As of Now i am manually copying the code and modifying it for each range of calls it needs to transfer. so there in lies the issue, inherently it will be limited by the number of times i wish to copy what i have existing. I intend to modify the code to loop and perform the copy paste between the workbooks until it reaches an empty cell in "book1" however every attempt i have made has failed, it only continually works the same ranges over and over unless i manually copy the code and modify for each new line. i fear i do not fully understand the range rows and cell aspects when it comes to relatives and absolutes and the proper syntax on how to call the out accurately. how do i achieve this? Any help would be appreciated.
Public Sub macro_54() ' Keyboard Shortcut: Ctrl+p Dim StartTime As Double Dim SecondsElapsed As Double StartTime = Timer Workbooks.Open ("C:\Users\Legacy\Desktop\DMAutoCalcs.xlsm") Windows("Book1.xlsm").Activate Range("a2:l2").Select Selection.Copy Windows("DMAutoCalcs.xlsm").Activate Range("a1:q1").Select Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False 'Refresh ActiveWorkbook.RefreshAll Application.Wait (Now + TimeValue("0:00:03")) ActiveWorkbook.RefreshAll Windows("DMAutoCalcs.xlsm").Activate Range("T2:x2").Select 'Application.CutCopyMode = False Selection.Copy Windows("Book1.xlsm").Activate Range("M2:q2").Select Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False ' copy from calcs pricing info and past into pricelist ' return to pricelist ' Selects cell down 1 row from active cell. 'New Line Windows("Book1.xlsm").Activate Range("a3:l3").Select Selection.Copy Windows("DMAutoCalcs.xlsm").Activate Range("a1:q1").Select Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False ' Refresh ActiveWorkbook.RefreshAll Application.Wait (Now + TimeValue("0:00:03")) ActiveWorkbook.RefreshAll Windows("DMAutoCalcs.xlsm").Activate Range("T2:x2").Select 'Application.CutCopyMode = False Selection.Copy Windows("Book1.xlsm").Activate Range("M3:q3").Select Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False ' copy from calcs pricing info and past into pricelist ' return to pricelist ' Selects cell down 1 row from active cell. 'New Line Windows("Book1.xlsm").Activate Range("a4:l4").Select Selection.Copy Windows("DMAutoCalcs.xlsm").Activate Range("a1:q1").Select Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False ' Refresh ActiveWorkbook.RefreshAll Application.Wait (Now + TimeValue("0:00:03")) ActiveWorkbook.RefreshAll Windows("DMAutoCalcs.xlsm").Activate Range("T2:x2").Select 'Application.CutCopyMode = False Selection.Copy Windows("Book1.xlsm").Activate Range("M4:q4").Select Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False ' copy from calcs pricing info and past into pricelist ' return to pricelist ' ' Selects cell down 1 row from active cell. ' And so on and so forth.... Windows("DMAutoCalcs.xlsm").Activate ActiveWorkbook.Close savechanges:=False Windows("Book1.xlsm").Activate 'Determine how many seconds code took to run SecondsElapsed = Round(Timer - StartTime, 2) 'Notify user in seconds MsgBox "All Ranges Updated, Calc sheet closed successfully in " & SecondsElapsed & " seconds", vbInformation End Sub