I want to make a loop in excel that cycles through cells and sets them as variable and uses that variable in SAP. I have the first variable in cell A46.
Sub CustomList()
Dim LR As Long, i As Long
Range("A46").Select
Do
j = ActiveCell.Value
Call SAPExportCustom
ActiveCell.Offset(1).Activate 'Move one cell down
Loop Until ActiveCell.Value <> "" 'Check if cell still has number
End Sub
--------------------------
Sub SAPExportCustom()
Set SapGuiAuto = GetObject("SAPGUI") 'Get the SAP GUI Scripting object
Set SAPApp = SapGuiAuto.GetScriptingEngine 'Get the currently running SAP GUI
Set SAPCon = SAPApp.Children(0) 'Get the first system that is currently connected
Set session = SAPCon.Children(0) 'Get the first session (window) on that connection
session.findById("wnd[0]").maximize
session.findById("wnd[0]/usr/txt[35,5]").Text = j.Value 'Work center
...
session.findById("wnd[1]/usr/ctxtDY_FILENAME").Text = j.Value & ".txt"
End Sub
I expect then for the code co back to CustomList, move one cell down to A47 and copy that and run the SAPExportCustom again with new variable.