none
Incrementing Serial Numbers with Send Key Function RRS feed

  • Question

  • I am trying to get Excel to write a series of incremented serial numbers to an external program. 
    I need 10 per line, then for the code to send ENTER and start writing on the next line.
    Following is my current code:

    For i = 0 To qty - 1
    SendKeys prefix_sn & next_sn + i & ","
    Next i

    Thanks
    Thursday, October 3, 2013 10:03 AM

All replies

  • To get the groupings of 10

    j = 0
    For i = 0 To qty - 1
        j = j + 1
        SendKeys prefix_sn & next_sn + i
        If j = 10 Then
            SendKeys "{ENTER}"
            j = 0
        Else
            SendKeys ","
        End If
    Next i

    You might want to format i for a fixed number of digits, like

    Format(i,"0000")

    depending on what qty is...


    Thursday, October 3, 2013 1:04 PM