MrExcel Message Board


Go Back   MrExcel Message Board > Question Forums > Excel Questions

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
Prev Previous Post   Next Post Next
Old Mar 9th, 2004, 02:24 AM   #1
whiteghost
 
whiteghost's Avatar
 
Join Date: Nov 2002
Location: spain
Posts: 500
Default modify inputboxs so cancel = exit sub

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
the macro position the input , the loopcount input box allowser to define how many rows they want to add. What I want to be able to do is exit the sub if cancel is clicked on typetext, codetext, quantext or pricetext.

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.
whiteghost is offline   Reply With Quote
 

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT +1. The time now is 01:04 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
All contents Copyright 1998-2009 by MrExcel Consulting.