Hello..
I am new to VBA excel ..
I have a piece of VBA to be run on SAP application.
this code is running and should take value from cell in A & B but this is running only take value in cell A. it's does not touch cell B at all.
Also when there is NO further value / empty , the loop should be stop.
could you please advice what the syntax should be in this case?
Thank you .
Dim vNilai As Variant
With SAPSesi
.findById("wnd[0]").maximize
.findById("wnd[0]/tbar[0]/okcd").Text = "/NMM02"
.findById("wnd[0]").sendVKey 0
For Each vNilai In Workbooks("LoopTrial.xls").Worksheets("Sheet1").Range("A2:A20,B2:B20")
.findById("wnd[0]/usr/ctxtRMMG1-MATNR").Text = vNilai
.findById("wnd[0]/usr/ctxtRMMG1-MATNR").caretPosition = 8
.findById("wnd[0]").sendVKey 0
.findById("wnd[0]").sendVKey 0
'ActiveCell.Offset(0, 1).Select
.findById("wnd[0]/usr/tabsTABSPR1/tabpSP13/ssubTABFRA1:SAPLMGMM:2000/subSUB4:SAPLMGD1:2486/txtMARC-EISBE").Text = vNilai
.findById("wnd[0]/usr/tabsTABSPR1/tabpSP13/ssubTABFRA1:SAPLMGMM:2000/subSUB4:SAPLMGD1:2486/txtMARC-EISBE").SetFocus
.findById("wnd[0]/usr/tabsTABSPR1/tabpSP13/ssubTABFRA1:SAPLMGMM:2000/subSUB4:SAPLMGD1:2486/txtMARC-EISBE").caretPosition = 2
.findById("wnd[0]").sendVKey 0
.findById("wnd[0]/tbar[0]/btn[11]").press
Next vNilai
.findById("wnd[0]/tbar[0]/okcd").Text = "/n"
.findById("wnd[0]").sendVKey 0
End With
below is the value in cell A&B
-- removed inline image ---
<table border="0" cellpadding="0" cellspacing="0" width="310"><colgroup><col style="width:48pt" width="64"> <col style="mso-width-source:userset;mso-width-alt:5046;width:104pt" width="138"> <col style="mso-width-source:userset;mso-width-alt:3949;width:81pt" width="108"> </colgroup><tbody><tr style="height:12.75pt" height="17"> <td class="xl24" style="height:12.75pt;width:48pt" height="17" width="64">
</td> <td class="xl24" style="width:104pt" width="138">A</td> <td class="xl25" style="width:81pt" width="108">B</td> </tr> <tr style="height:12.75pt" height="17"> <td class="xl24" style="height:12.75pt" height="17">1</td> <td class="xl24">MATNR</td> <td class="xl25">EISBE</td> </tr> <tr style="height:12.75pt" height="17"> <td class="xl24" style="height:12.75pt" height="17">2</td> <td class="xl24">96041313</td> <td class="xl25">26</td> </tr> <tr style="height:12.75pt" height="17"> <td class="xl24" style="height:12.75pt" height="17">3</td> <td class="xl24">96487181</td> <td class="xl25">51</td> </tr> <tr style="height:12.75pt" height="17"> <td class="xl24" style="height:12.75pt" height="17">4</td> <td class="xl24">2421241</td> <td class="xl25">25</td> </tr> <tr style="height:12.75pt" height="17"> <td class="xl24" style="height:12.75pt" height="17">5</td> <td class="xl24">2408447</td> <td class="xl25">30</td> </tr> <tr style="height:12.75pt" height="17"> <td class="xl24" style="height:12.75pt" height="17">6</td> <td class="xl24">2421025</td> <td class="xl25">15</td> </tr> <tr style="height:12.75pt" height="17"> <td class="xl24" style="height:12.75pt" height="17">7</td> <td class="xl24">3067001</td> <td class="xl25">10</td> </tr> <tr style="height:12.75pt" height="17"> <td class="xl24" style="height:12.75pt" height="17">8</td> <td class="xl24">2419745</td> <td class="xl25">5</td> </tr> </tbody></table>
-- removed inline image ---
Brgds,
Rohmadi
I am new to VBA excel ..
I have a piece of VBA to be run on SAP application.
this code is running and should take value from cell in A & B but this is running only take value in cell A. it's does not touch cell B at all.
Also when there is NO further value / empty , the loop should be stop.
could you please advice what the syntax should be in this case?
Thank you .
Dim vNilai As Variant
With SAPSesi
.findById("wnd[0]").maximize
.findById("wnd[0]/tbar[0]/okcd").Text = "/NMM02"
.findById("wnd[0]").sendVKey 0
For Each vNilai In Workbooks("LoopTrial.xls").Worksheets("Sheet1").Range("A2:A20,B2:B20")
.findById("wnd[0]/usr/ctxtRMMG1-MATNR").Text = vNilai
.findById("wnd[0]/usr/ctxtRMMG1-MATNR").caretPosition = 8
.findById("wnd[0]").sendVKey 0
.findById("wnd[0]").sendVKey 0
'ActiveCell.Offset(0, 1).Select
.findById("wnd[0]/usr/tabsTABSPR1/tabpSP13/ssubTABFRA1:SAPLMGMM:2000/subSUB4:SAPLMGD1:2486/txtMARC-EISBE").Text = vNilai
.findById("wnd[0]/usr/tabsTABSPR1/tabpSP13/ssubTABFRA1:SAPLMGMM:2000/subSUB4:SAPLMGD1:2486/txtMARC-EISBE").SetFocus
.findById("wnd[0]/usr/tabsTABSPR1/tabpSP13/ssubTABFRA1:SAPLMGMM:2000/subSUB4:SAPLMGD1:2486/txtMARC-EISBE").caretPosition = 2
.findById("wnd[0]").sendVKey 0
.findById("wnd[0]/tbar[0]/btn[11]").press
Next vNilai
.findById("wnd[0]/tbar[0]/okcd").Text = "/n"
.findById("wnd[0]").sendVKey 0
End With
below is the value in cell A&B
-- removed inline image ---
<table border="0" cellpadding="0" cellspacing="0" width="310"><colgroup><col style="width:48pt" width="64"> <col style="mso-width-source:userset;mso-width-alt:5046;width:104pt" width="138"> <col style="mso-width-source:userset;mso-width-alt:3949;width:81pt" width="108"> </colgroup><tbody><tr style="height:12.75pt" height="17"> <td class="xl24" style="height:12.75pt;width:48pt" height="17" width="64">
</td> <td class="xl24" style="width:104pt" width="138">A</td> <td class="xl25" style="width:81pt" width="108">B</td> </tr> <tr style="height:12.75pt" height="17"> <td class="xl24" style="height:12.75pt" height="17">1</td> <td class="xl24">MATNR</td> <td class="xl25">EISBE</td> </tr> <tr style="height:12.75pt" height="17"> <td class="xl24" style="height:12.75pt" height="17">2</td> <td class="xl24">96041313</td> <td class="xl25">26</td> </tr> <tr style="height:12.75pt" height="17"> <td class="xl24" style="height:12.75pt" height="17">3</td> <td class="xl24">96487181</td> <td class="xl25">51</td> </tr> <tr style="height:12.75pt" height="17"> <td class="xl24" style="height:12.75pt" height="17">4</td> <td class="xl24">2421241</td> <td class="xl25">25</td> </tr> <tr style="height:12.75pt" height="17"> <td class="xl24" style="height:12.75pt" height="17">5</td> <td class="xl24">2408447</td> <td class="xl25">30</td> </tr> <tr style="height:12.75pt" height="17"> <td class="xl24" style="height:12.75pt" height="17">6</td> <td class="xl24">2421025</td> <td class="xl25">15</td> </tr> <tr style="height:12.75pt" height="17"> <td class="xl24" style="height:12.75pt" height="17">7</td> <td class="xl24">3067001</td> <td class="xl25">10</td> </tr> <tr style="height:12.75pt" height="17"> <td class="xl24" style="height:12.75pt" height="17">8</td> <td class="xl24">2419745</td> <td class="xl25">5</td> </tr> </tbody></table>
-- removed inline image ---
Brgds,
Rohmadi