Range Variable VBA

jamesmev

Board Regular
Joined
Apr 9, 2015
Messages
231
Office Version
  1. 365
Platform
  1. Windows
I have the below code. That is running from EXCEL to SAP GUI
However, it is taking one cell at a time and loading.
I need it to take a larger range in the column (select 3 down in a column from the last three, etc).
I am at a loss on this one. any help?

VBA Code:
Dim row As Long  'Excel Workbook Row
Dim row1 As Integer 'SAP Fast Entry Row
Set tbl = excelApp.ActiveCell.CurrentRegion

myValue = InputBox("What is the starting line?", "Starting Line", "4")
SkipApplyToAll = 0
OverwriteApplyToAll = 0

 
With session
If Left(session.ActiveWindow.Text, 15) <> "ACCESS" Then
    If session.ActiveWindow.Text = "Download file" Then
        .findById("wnd[1]/tbar[0]/btn[3]").press
        .findById("wnd[0]").sendVKey 12      'Sends Window to main screen
    Else
        .findById("wnd[0]").sendVKey 12      'Sends Window to main screen
    End If
End If

.findById("wnd[0]/tbar[0]/okcd").Text = "1"
.findById("wnd[0]/tbar[0]/btn[0]").press
.findById("wnd[0]/usr/ctxtRV13A-KSCHL").Text = "2"
.findById("wnd[0]/tbar[1]/btn[17]").press
.findById("wnd[1]/usr/sub:SAPLV14A:0100/radRV130-SELKZ[1,0]").Select
'.findById("wnd[1]/usr/sub:SAPLV14A:0100/radRV130-SELKZ[1,0]").SetFocus
.findById("wnd[1]/tbar[0]/btn[0]").press
End With

For row = myValue To tbl.Rows.Count
row1 = 0
ReStrt:
Cust = tbl.Cells(row, 3).Value

With session
.findById("wnd[0]/usr/ctxtKOMG-VKORG").Text = tbl.Cells(row, 2).Value 'Sales Organization
.findById("wnd[0]/usr/ctxtKOMG-VTWEG").Text = "0" 'Distribution Channel
.findById("wnd[0]/usr/ctxtKOMG-KUNNR").Text = tbl.Cells(row, 3).Value 'Customer Number
.findById("wnd[0]/usr/ctxtKOMG-/SCL/BRAND").Text = tbl.Cells(ro).Value 'X
.findById("wnd[0]/usr/tblSAPMV13ATCTRL_FAST_ENTRY/ctxtKOMG-/SCL/PKG[0," & row1 & "]").Text = tbl.Cells(row, 5).Value 'Y
.findById("wnd[0]/usr/tblSAPMV13ATCTRL_FAST_ENTRY/txtKONP-KBETR[4," & row1 & "]").Text = tbl.Cells(row, 6).Value 'Z
.findById("wnd[0]/usr/tblSAPMV13ATCTRL_FAST_ENTRY/ctxtKONP-KMEIN[7," & row1 & "]").Text = tbl.Cells(row, 7).Value 'Condition Unit
.findById("wnd[0]/usr/tblSAPMV13ATCTRL_FAST_ENTRY/ctxtRV13A-DATAB[10," & row1 & "]").Text = tbl.Cells(row, 8).Text 'Start Date
.findById("wnd[0]/usr/tblSAPMV13ATCTRL_FAST_ENTRY/ctxtRV13A-DATBI[11," & row1 & "]").Text = tbl.Cells(row, 9).Text 'End Date

1633028919621.png



Thank you for any help!
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result

jamesmev

Board Regular
Joined
Apr 9, 2015
Messages
231
Office Version
  1. 365
Platform
  1. Windows
I need the myvalue to be the first selected.
Then it grabs the myvalue +2 then from that point it goes down the sheet
and the next 3 from there and so on until the end of the data set.

I didn't build this - I'm just trying to make it faster (1 at a time takes too long) :(

PLEASE HELP!! ?
 

Forum statistics

Threads
1,176,512
Messages
5,903,474
Members
435,031
Latest member
traceson

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top