0

My script is working however there is one field I can't figure out how to change in the VBA script. I need to change it based on an entry in Excel.

Here is the script where I am experiencing the issue, the value I have bolded (4).

I've tested when changing the value manually and it works. But what I need is to change the value (4) to different values based on data in the excel file.

Session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\01/ssubSUBSCREEN_BODY:SAPMV50A:1202/tblSAPMV50ATC_LIPS_OVER_INB").getAbsoluteRow(4).Selected = False Session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\01/ssubSUBSCREEN_BODY:SAPMV50A:1202/tblSAPMV50ATC_LIPS_OVER_INB/txtLIPS-POSNR[0,4]").SetFocus Session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\01/ssubSUBSCREEN_BODY:SAPMV50A:1202/tblSAPMV50ATC_LIPS_OVER_INB/txtLIPS-POSNR[0,4]").caretPosition = 0

Example: If Excel file says "20" in column G, then change above (4) to (1) So simply put, replace the value in the script based on excel value.

Boghyon Hoffmann
  • 17,103
  • 12
  • 72
  • 170
Skavis
  • 3
  • 2

1 Answers1

0

Yes, of course, you need a case statement. I'd do it like this:

Select Case value = test_condition

   Case condition_1
      rowResult = 1

   Case condition_2
      rowResult = 2

   ...

   Case condition_n
      result_n

 [ Case Else
      result_else ]

End Select

Then SAP code would be:

Session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\01/ssubSUBSCREEN_BODY:SAPMV50A:1202/tblSAPMV50ATC_LIPS_OVER_INB").getAbsoluteRow(rowResult).Selected = False
Session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\01/ssubSUBSCREEN_BODY:SAPMV50A:1202/tblSAPMV50ATC_LIPS_OVER_INB/txtLIPS-POSNR[0," & CStr(rowResult) & "]").SetFocus
Session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\01/ssubSUBSCREEN_BODY:SAPMV50A:1202/tblSAPMV50ATC_LIPS_OVER_INB/txtLIPS-POSNR[0," & CStr(rowResult) & "]").caretPosition = 0
Jean Rostan
  • 1,056
  • 1
  • 8
  • 16
  • Here is a screenshot of the excel file. https://imgur.com/a/w0AnY Forgive my ignorance but what would I put in in exactly as I am very new to all of this? Each line runs then repeats for the next line. So Column G is "40" the script needs to have 3. Next line is "30" so script needs to run as 2 (and so on) – Skavis Apr 06 '18 at 19:07
  • @Skavis can't access your picture at work. But everything is in my answer, your condition 1 is for instance 40, and the rowResult is 3. Gl – Jean Rostan Apr 06 '18 at 19:09