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

Hi all,

Im using the code below to delete a range. What i would also like i
once the range has been deleted, if the user clicks the buttin again
an error message 'you have already deleted this range
appears....rather than a debug message.

How would i do this??

Cheers all!!!!

Private Sub CommandButton5_Click()
Dim rng As Range, x As Single
Dim wsquote As Worksheet
Set wsquote = Worksheets("sheet1")
Set rng = wsquote.Range("knife2")
x = rng.Rows.Count
wsquote.Range("knife2").ClearContents
rng.Offset(0, 0).Resize(x).EntireRow.Delete
'Sheets("sheet 1").Range("range").ClearContents
End Su

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default User message

Dim rng As Range, x As Single
Dim wsquote As Worksheet
Set wsquote = Worksheets("sheet1")
On Error Resume Next
Set rng = wsquote.Range("knife2")
If Err.Number = 0 Then
x = rng.Rows.Count
wsquote.Range("knife2").ClearContents
rng.Offset(0, 0).Resize(x).EntireRow.Delete
'Sheets("sheet 1").Range("range").ClearContents
End If

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"gavmer " wrote in message
...
Hi all,

Im using the code below to delete a range. What i would also like is
once the range has been deleted, if the user clicks the buttin again,
an error message 'you have already deleted this range'
appears....rather than a debug message.

How would i do this??

Cheers all!!!!

Private Sub CommandButton5_Click()
Dim rng As Range, x As Single
Dim wsquote As Worksheet
Set wsquote = Worksheets("sheet1")
Set rng = wsquote.Range("knife2")
x = rng.Rows.Count
wsquote.Range("knife2").ClearContents
rng.Offset(0, 0).Resize(x).EntireRow.Delete
'Sheets("sheet 1").Range("range").ClearContents
End Sub


---
Message posted from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default User message

Hi Bob,

Good to hear from you. I tried your code but no error message wa
presented. How do i get the error message 'you have already deleted th
range' to appear if the range is no longer.

??????

Cheers!!!!

--
Message posted from http://www.ExcelForum.com

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default User message

Dim rng As Range, x As Single
Dim wsquote As Worksheet
Set wsquote = Worksheets("sheet1")
On Error Resume Next
Set rng = wsquote.Range("knife2")
If Err.Number = 0 Then
x = rng.Rows.Count
wsquote.Range("knife2").ClearContents
rng.Offset(0, 0).Resize(x).EntireRow.Delete
'Sheets("sheet 1").Range("range").ClearContents
Else
MsgBox "have already deleted the range'"
End If


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"gavmer " wrote in message
...
Hi Bob,

Good to hear from you. I tried your code but no error message was
presented. How do i get the error message 'you have already deleted the
range' to appear if the range is no longer.

??????

Cheers!!!!!


---
Message posted from http://www.ExcelForum.com/



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default User message

Bob,

You are spot on......as always!!!!

Thank you!!!


---
Message posted from http://www.ExcelForum.com/



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default User message

It's a pleasure as always Gav.

Bob

"gavmer " wrote in message
...
Bob,

You are spot on......as always!!!!

Thank you!!!


---
Message posted from http://www.ExcelForum.com/



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
Want to get user selections from a message box using option buttons Walt Excel Discussion (Misc queries) 1 November 4th 05 03:04 AM
Displaying a message in a message box without requiring user to click anything to proceed Android[_2_] Excel Programming 2 June 25th 04 06:44 PM
Status Message User Form in Excel '97 Brad[_11_] Excel Programming 2 December 12th 03 07:57 PM
Asking user to print and error message Olly[_3_] Excel Programming 1 November 17th 03 01:18 PM
How can I ensure a message to the computer user is aknowledged? Gary Ainsworth Excel Programming 1 November 17th 03 10:37 AM


All times are GMT +1. The time now is 08:46 AM.

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

About Us

"It's about Microsoft Excel"