Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default vb cancel button


i am trying to find out what to write so that when you hit the cancel
button on the input box, nothing else happens. the cancel box will go
away.

here is my code


Dim deleteline As Integer
Dim count As Integer
count = 1
deleteline = InputBox("Enter Item Line to Delete")
Do While Range("f8").Offset(deleteline + count - 1) 0
Range("g8").Offset(deleteline + count - 1, 0) =
Range("g8").Offset(deleteline + count, 0)
Range("i8").Offset(deleteline + count - 1, 0) =
Range("i8").Offset(deleteline + count, 0)
count = count + 1
Loop
Range("f8").Offset(deleteline + count - 1, 0) = ""
Range("a1") = Range("a1") - 1
Range("f8").Offset(Range("a1") + 1, 0) = ""


--
kckar
------------------------------------------------------------------------
kckar's Profile: http://www.excelforum.com/member.php...o&userid=25322
View this thread: http://www.excelforum.com/showthread...hreadid=533353

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default vb cancel button

Add a test to the value of deleteline. Something like the following code.
(Just as an aside don't use "count" as a variable as it is a reserved word.
Use something like iCount or intCount. While in this case count probably
won't hurt you it won't help and it is a really bad habit to get into.)

Dim deleteline As Integer
Dim count As Integer
count = 1
deleteline = InputBox("Enter Item Line to Delete")
if deleteline = "" then exit sub
Do While Range("f8").Offset(deleteline + count - 1) 0
Range("g8").Offset(deleteline + count - 1, 0) =
Range("g8").Offset(deleteline + count, 0)
Range("i8").Offset(deleteline + count - 1, 0) =
Range("i8").Offset(deleteline + count, 0)
count = count + 1
Loop
Range("f8").Offset(deleteline + count - 1, 0) = ""
Range("a1") = Range("a1") - 1
Range("f8").Offset(Range("a1") + 1, 0) = ""


--
HTH...

Jim Thomlinson


"kckar" wrote:


i am trying to find out what to write so that when you hit the cancel
button on the input box, nothing else happens. the cancel box will go
away.

here is my code


Dim deleteline As Integer
Dim count As Integer
count = 1
deleteline = InputBox("Enter Item Line to Delete")
Do While Range("f8").Offset(deleteline + count - 1) 0
Range("g8").Offset(deleteline + count - 1, 0) =
Range("g8").Offset(deleteline + count, 0)
Range("i8").Offset(deleteline + count - 1, 0) =
Range("i8").Offset(deleteline + count, 0)
count = count + 1
Loop
Range("f8").Offset(deleteline + count - 1, 0) = ""
Range("a1") = Range("a1") - 1
Range("f8").Offset(Range("a1") + 1, 0) = ""


--
kckar
------------------------------------------------------------------------
kckar's Profile: http://www.excelforum.com/member.php...o&userid=25322
View this thread: http://www.excelforum.com/showthread...hreadid=533353


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 225
Default vb cancel button

Use Application.InputBox instead of just InputBox, and you'll get
a value of False returned if the user hits Cancel (or the Escape key).

See the Excel Help on InputBox for the subtle distinction between
these two.

hth
Andrew Taylor

kckar wrote:
i am trying to find out what to write so that when you hit the cancel
button on the input box, nothing else happens. the cancel box will go
away.

here is my code


Dim deleteline As Integer
Dim count As Integer
count = 1
deleteline = InputBox("Enter Item Line to Delete")
Do While Range("f8").Offset(deleteline + count - 1) 0
Range("g8").Offset(deleteline + count - 1, 0) =
Range("g8").Offset(deleteline + count, 0)
Range("i8").Offset(deleteline + count - 1, 0) =
Range("i8").Offset(deleteline + count, 0)
count = count + 1
Loop
Range("f8").Offset(deleteline + count - 1, 0) = ""
Range("a1") = Range("a1") - 1
Range("f8").Offset(Range("a1") + 1, 0) = ""


--
kckar
------------------------------------------------------------------------
kckar's Profile: http://www.excelforum.com/member.php...o&userid=25322
View this thread: http://www.excelforum.com/showthread...hreadid=533353


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cancel button to cancel the whole macro excelnut1954 Excel Programming 3 January 17th 06 08:27 PM
InputBox - cancel button Greg Billinge Excel Programming 4 October 11th 04 06:45 PM
Cancel button IamHaxer Excel Programming 3 June 24th 04 05:19 PM
Cancel Button Matt Excel Programming 3 February 3rd 04 11:23 PM
input box cancel button Ian Mangelsdorf Excel Programming 1 August 28th 03 09:05 PM


All times are GMT +1. The time now is 11:19 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"