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

I have command button for deleting values in some cells, but it doesn't
work. Can someone help? Thanks !!

Private Sub cmdDelete_Click()
Dim a As Boolean

a = MsgBox("Do you want to delete?", vbYesNo)
Select Case a
Case a = vbYes

Worksheets(1).Range("C4:C13,E28:G32,E34:G36,E38:G4 8,E50:G57").Select
Selection.ClearContents
Case a = vbNo
ActiveSheet.Range("C4").Select
End Select
End Sub

Thanks!!


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,327
Default Delete with command button?


Dim a As Long
'...
Case vbYes
'...
Case vbNo
'...

HTH. Best wishes Harald

"John" skrev i melding
...
I have command button for deleting values in some cells, but it doesn't
work. Can someone help? Thanks !!

Private Sub cmdDelete_Click()
Dim a As Boolean

a = MsgBox("Do you want to delete?", vbYesNo)
Select Case a
Case a = vbYes

Worksheets(1).Range("C4:C13,E28:G32,E34:G36,E38:G4 8,E50:G57").Select
Selection.ClearContents
Case a = vbNo
ActiveSheet.Range("C4").Select
End Select
End Sub

Thanks!!




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,163
Default Delete with command button?

For some strange reason the VB developers did not make vbYes and vbNo
convertible directly to Boolean values. VBYes = 6 and vbNo = 7; converted to
Boolean they would both become True (i.e., non-zero). You need to Dim a as
an Integer variable.

"John" wrote:

I have command button for deleting values in some cells, but it doesn't
work. Can someone help? Thanks !!

Private Sub cmdDelete_Click()
Dim a As Boolean

a = MsgBox("Do you want to delete?", vbYesNo)
Select Case a
Case a = vbYes

Worksheets(1).Range("C4:C13,E28:G32,E34:G36,E38:G4 8,E50:G57").Select
Selection.ClearContents
Case a = vbNo
ActiveSheet.Range("C4").Select
End Select
End Sub

Thanks!!



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Delete with command button?

Presumably because vbYes and VbNo are part of a much bigger enumeration, and
there are only two Boolean values.

You could always declare ans as vbMsgboxResult.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"K Dales" wrote in message
...
For some strange reason the VB developers did not make vbYes and vbNo
convertible directly to Boolean values. VBYes = 6 and vbNo = 7; converted

to
Boolean they would both become True (i.e., non-zero). You need to Dim a

as
an Integer variable.

"John" wrote:

I have command button for deleting values in some cells, but it doesn't
work. Can someone help? Thanks !!

Private Sub cmdDelete_Click()
Dim a As Boolean

a = MsgBox("Do you want to delete?", vbYesNo)
Select Case a
Case a = vbYes

Worksheets(1).Range("C4:C13,E28:G32,E34:G36,E38:G4 8,E50:G57").Select
Selection.ClearContents
Case a = vbNo
ActiveSheet.Range("C4").Select
End Select
End Sub

Thanks!!





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
Delete command button gavmer[_96_] Excel Programming 0 October 19th 04 12:56 AM
Delete command button BrianB Excel Programming 0 October 18th 04 10:28 AM
Delete a custom button by holding down the ALT key and dragging the button off the toolbar Stephen[_8_] Excel Programming 0 April 4th 04 02:22 PM
Command Button vs Control Button RGibson Excel Programming 1 October 14th 03 02:24 AM
copy and delete command button Mark Kubicki Excel Programming 0 October 6th 03 08:20 PM


All times are GMT +1. The time now is 11:13 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"