![]() |
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 |
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 |
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 |
All times are GMT +1. The time now is 07:27 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com