cancel
Showing results for 
Search instead for 
Did you mean: 

Scripting-Need Loop Help

Former Member
0 Kudos

Hi everyone!

I am trying to create a script to create a sales order (t-code VA01) with multiple line items.

My script code is using counter i to go down each row in excel to pull in the data (for each sales order),

but to create each line item within each sales order, i need it to read across a few columns so that i can make multiple line items.

Any ideas?


Accepted Solutions (0)

Answers (3)

Answers (3)

thomas_brutigam2
Active Participant
0 Kudos

Hi Christina,

here's a little Example:

For Example there are 4 Rows to navigate through:


For i = 1 to 100 'only for example

debug.Print xlssht.Cells(i,1).Value   '<- that is Cell "A1"

debug.Print xlssht.Cells(i,2).Value   'Cell "B1"

debug.Print xlssht.Cells(i,3).Value '... and so on  ...
debug.print xlssht.Cells(i,4).value

next i

So if the first Loop is through you will enter the next Column 2

Using the Cell property of Excel is much faster as the "Range" property...

stefan_schnell
Active Contributor
0 Kudos

Hello Christina,

as far as I understand your problem correct, I think you need a loop in a loop.

Look at these example:

For i = 1 To RowCount

  'First code here to fill your fields

  For j = 1 To ColumnCount

    'Second code here to make your multiple line items

  Next j

Next i

Cheers

Stefan

Former Member
0 Kudos

I am using vbscript