Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

When I press cancel, puts zero (0) by default

Status
Not open for further replies.

tvlatko

IS-IT--Management
Jun 27, 2002
2
0
0
US
I’m working on a financial model in excel. I have this pop-up window whenever I open one of the percentage rates. It asks what year do I won’t to work on. The problem is if I press cancel it puts 0 value instead of just having the values that are there.

Here is the code in visual basic.
What changes should I make?

ElseIf btnEnterYears.Value = True Then
Sheets(“Workbook Map”).Activate
Range(“CURRYR”).Select
ActiveCell.Value= Val(InputBox(“Enter the Base Year.”,”Base Year”))
ActiveCell.Offset(1,0).Select
Range(“A1”).Select

Thanks in advance,
vladimir
 
What about this way: put code under keypres event and
.....(your code)
if Keyascii =27 then
exit sub
 
dim inputVal as string

inputVal=InputBox(“Enter the Base Year.”,”Base Year”)
' StrPtr(inputVal)=0 if cancel was clicked
if StrPtr(inputVal)<>0 then
ActiveCell.Value= Val(inputVal)
end if
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top