View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Rick Rothstein \(MVP - VB\)[_1443_] Rick Rothstein \(MVP - VB\)[_1443_] is offline
external usenet poster
 
Posts: 1
Default Generate list of number

Give this code a try in your Generate button's Click event...

Private Sub CommandButton1_Click()
Dim X As Long
Dim LastColumn As Long
Dim Number1 As Variant
Dim Number2 As Variant
Dim TBox1 As String
Dim TBox2 As String
TBox1 = TextBox1.Text
TBox2 = TextBox2.Text
If TBox1 Like String(Len(TBox1), "#") And Len(TBox2) < 29 Then
Number1 = CDec(TBox1)
If TBox2 Like String(Len(TBox2), "#") And Len(TBox2) < 29 Then
Number2 = CDec(TBox2)
LastColumn = Cells(1, Columns.Count).End(xlToLeft).Column
For X = 0 To Number2 - Number1
Cells(X + 1, LastColumn + 1).Value = "'" & CStr(Number1 + X)
Next
Else
MsgBox "Bad entry in TextBox2"
End If
Else
MsgBox "Bad entry in TextBox1"
End If
End Sub

Rick


"Sinner" wrote in message
...
Hi,

I want to generate a list in excel using a simple form.

-------------------------------------------------------
Start Range:<TEXT BOX
End Range:<TEXT BOX

<Generate button
-------------------------------------------------------
Start value: 7910050200300078970
End Value: 7910050200300078979

Upon generate, it should generate list like:

7910050200300078970
7910050200300078971
7910050200300078972
7910050200300078973
7910050200300078974
7910050200300078975
7910050200300078976
7910050200300078977
7910050200300078978
7910050200300078979
-------------------------------------------------------
After first list is generated in columnA, it should move on to next
blank column & generate list for new start/end values and so on.
Would appreciate an excel/VB form solution.