![]() |
I'm a newbie
I have a question. I want to ask the user for a number. (I have a
dialog box created.) For example, if the user enters 5. I want to place A, B, C, D, and E in column A1:A5. If the user enters 26. I want to place A, B, ..., Z in column A1:A26. I can not figure out how to do this. THANKS |
I'm a newbie
So you have a dialog with probably a textbox and a button on it. Here is
some code you could put in the button's click event: Private Sub CommandButton1_Click() Dim i As Integer, last As Integer If IsNumeric(TextBox1.Value) Then last = TextBox1.Value If last < 1 Or last 26 Then MsgBox "Enter a number between 1 and 26", vbExclamation GoTo ExitSub End If For i = 1 To last Cells(1, i) = Chr(64 + i) Next i Else MsgBox "Enter a number between 1 and 26", vbExclamation End If ExitSub: Unload Me End Sub Chr(65) yields an "A", Chr(64+26) yields the "Z". Add another 32 to get the lowercase equivalents. With kind regards, Ton Teuns *** Sent via Developersdex http://www.developersdex.com *** |
I'm a newbie
You could do something like this:
Sub test() sp = 65 i = 1 Do Until i 10 Cells(i, 1).Value = Chr$(sp) i = i + 1 sp = sp + 1 Loop End Sub Just have your results from your box replace the value of 10 in the "do" statement. Brian wrote in message oups.com... I have a question. I want to ask the user for a number. (I have a dialog box created.) For example, if the user enters 5. I want to place A, B, C, D, and E in column A1:A5. If the user enters 26. I want to place A, B, ..., Z in column A1:A26. I can not figure out how to do this. THANKS |
All times are GMT +1. The time now is 03:51 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com