![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Join Date: Nov 2002
Location: spain
Posts: 500
|
Hi
how can I modify this code or the inputboxes sothat if "cancel" is clicked on any of the inputboxes will exit the sub. Code:
Sub star1()
'
Dim loopcount As Integer
Dim i As Integer
loopcount = InputBox("how many rows?")
For i = 1 To loopcount
Range("a65536").Select
Dim x As Double
x = Range("a525").End(xlUp).Row + 1
Range("a" & x).Select
typetext = InputBox(prompt:="Enter Code.", Default:="PCode")
codetext = InputBox(prompt:="Enter coutry Code.", Default:="Country Code")
quantext = InputBox(prompt:="Enter quantity.", Default:="Qty.")
pricetext = InputBox(prompt:="Enter price.", Default:="")
ActiveCell.FormulaR1C1 = typetext
Range("a65536").End(xlUp).Offset(1, 0) = vbNullString
Range("a65536").End(xlUp).Offset(0, 0) = typetext
Range("a65536").End(xlUp).Offset(0, 2) = codetext
Range("a65536").End(xlUp).Offset(0, 4) = quantext
Range("a65536").End(xlUp).Offset(0, 5) = pricetext
Next i
x = Range("a525").End(xlUp).Row + 1
Range("a" & x).Select
End Sub
thanks
__________________
Grant me the serenity to accept the things I cannot change, the courage to change the things I cannot accept and the wisdom to hide the bodies of all the people who seriously pissed me off. |
|
|
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|