Be seen. Boost your question’s priority for more expert views and faster solutions
'Not sure this will ever be empty now... AC2 needs a value.. won't hurt to leave it there.
If IsEmpty(Cells(2, 29)) Then 'row then column (2, 29)) = AC2
Set rng = Range(Cells(2, 29), Cells(2, 29)) 'does not select range but remembers it
'Add a failure mode to task list, PurReqNum not generated.
Exit Sub 'Should never make it this far without being empty
Else
Set rng = Range(Cells(2, 29), Columns(29).End(xlDown)) 'range is now = rng
For Each c In rng ' loops thru rng
PurReqNumber = c ' sets c = to PurReqNumber
' c is a row, need to assign whatever is in column A = SO to use later in the procedure
' c is a row, need to assign whatever is in column B = Line to use later in the procedure
If c = "NoPurReqPassThru" Then 'Means this is a PassThru LnItem and wont get a PurReqNum
session.findById("wnd[0]/tbar[0]/okcd").Text = "me23n"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/tbar[1]/btn[17]").Press
session.findById("wnd[1]").sendVKey 4
session.findById("wnd[2]/usr/tabsG_SELONETABSTRIP/tabpTAB017").Select
session.findById("wnd[2]/usr/tabsG_SELONETABSTRIP/tabpTAB017/ssubSUBSCR_PRESEL:SAPLSDH4:0220/sub:SAPLSDH4:0220/txtG_SELFLD_TAB-LOW[0,24]").Text = SO
session.findById("wnd[2]/usr/tabsG_SELONETABSTRIP/tabpTAB017/ssubSUBSCR_PRESEL:SAPLSDH4:0220/sub:SAPLSDH4:0220/txtG_SELFLD_TAB-LOW[1,24]").Text = Line
session.findById("wnd[2]/usr/tabsG_SELONETABSTRIP/tabpTAB017/ssubSUBSCR_PRESEL:SAPLSDH4:0220/sub:SAPLSDH4:0220/txtG_SELFLD_TAB-LOW[1,24]").SetFocus
session.findById("wnd[2]/usr/tabsG_SELONETABSTRIP/tabpTAB017/ssubSUBSCR_PRESEL:SAPLSDH4:0220/sub:SAPLSDH4:0220/txtG_SELFLD_TAB-LOW[1,24]").caretPosition = 3
session.findById("wnd[2]/tbar[0]/btn[0]").Press
session.findById("wnd[2]/usr/lbl[31,3]").SetFocus
session.findById("wnd[2]/usr/lbl[31,3]").caretPosition = 2
session.findById("wnd[2]").sendVKey 2
session.findById("wnd[1]/tbar[0]/btn[24]").Press
session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0015/subSUB0:SAPLMEGUI:0030/subSUB1:SAPLMEGUI:1105/txtMEPO_TOPLINE-EBELN").SetFocus
session.findById("wnd[0]/usr/subSUB0:SAPLMEGUI:0015/subSUB0:SAPLMEGUI:0030/subSUB1:SAPLMEGUI:1105/txtMEPO_TOPLINE-EBELN").caretPosition = 0
session.findById("wnd[0]/tbar[0]/btn[15]").Press
SO = Range("A" & c.Row).Value
Line = Range("B" & c.Row).Value
Not sure where in the code you are grabbing a value from SAP but to refer to the cell in column AD on the same row as c use Range("AD" & c.Row).
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
From novice to tech pro — start learning today.
So either:
Cells(R, 30) = PTPurReqNum
or
Range("AD" & c.Row) = PTPurReqNum
Both say "Set cell AD# = to variable PTPurReqNum"
Putting it as:
PTPurReqNum = Range("AD" & c.Row)
Says "Set variable = to value of Cell"
If cell is blank, it would overwrite value of variable with blank.
Thanks
Rob H