PC Review


Reply
Thread Tools Rate Thread

Before Double Click Procedure

 
 
JDaywalt
Guest
Posts: n/a
 
      27th Mar 2008
I have a workbook that contains a sheet tab named Menu that contains a list
of the other 15 sheet tabs that exist in this workbook. These descriptions
are located in cells D216. I want to use cells A2:A16 as a double-click
prodedure whereby when the user double-clicks in the appropriate cell, it
will clear the contents plus any objects (if there are any) on the chosen
sheet tab. Below is the code I have built within the Menu worksheet---but
when I try to execute, I get a "subscript out of range" error on the row
indicated below.... Can someone help?

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Not Intersect(Target, Range("A2:A16")) Is Nothing Then
Dim ChosenSheet
ChosenSheet = Target.Offset(0, 3).Text
Sheets(ChosenSheet).Cells.ClearContents 'Here is the line that causes
error
On Error Resume Next
Sheets(ChosenSheet).DrawingObjects.Delete

Else
End If
End Sub
 
Reply With Quote
 
 
 
 
Jim Thomlinson
Guest
Posts: n/a
 
      27th Mar 2008
Could be a matter of spelling or blank spaces in the sheet names... How about
this.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Not Intersect(Target, Range("A2:A16")) Is Nothing Then
Dim wks as worksheet

on error resume next
set wks = worksheets(Target.Offset(0, 3).Text)
on error goto 0

if wks is nothing then
msgbox "sorry.. can't find sheet " & Target.Offset(0, 3).Text
else
wks.Cells.ClearContents
On Error Resume Next
wks.DrawingObjects.Delete
On error goto 0
End If
End Sub
--
HTH...

Jim Thomlinson


"JDaywalt" wrote:

> I have a workbook that contains a sheet tab named Menu that contains a list
> of the other 15 sheet tabs that exist in this workbook. These descriptions
> are located in cells D216. I want to use cells A2:A16 as a double-click
> prodedure whereby when the user double-clicks in the appropriate cell, it
> will clear the contents plus any objects (if there are any) on the chosen
> sheet tab. Below is the code I have built within the Menu worksheet---but
> when I try to execute, I get a "subscript out of range" error on the row
> indicated below.... Can someone help?
>
> Private Sub Worksheet_SelectionChange(ByVal Target As Range)
>
> If Not Intersect(Target, Range("A2:A16")) Is Nothing Then
> Dim ChosenSheet
> ChosenSheet = Target.Offset(0, 3).Text
> Sheets(ChosenSheet).Cells.ClearContents 'Here is the line that causes
> error
> On Error Resume Next
> Sheets(ChosenSheet).DrawingObjects.Delete
>
> Else
> End If
> End Sub

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
File explorer hangs when right-click, ctrl-c, shift-delete, double-click =?Utf-8?B?RG91Zw==?= Windows XP Networking 1 9th Oct 2010 07:46 AM
Double click right mouse not a double click Freddy Windows XP Internet Explorer 5 23rd Jan 2008 10:12 AM
Double click event invoked when no double click has occurred Michael Matuszak Microsoft Access Forms 0 6th Aug 2004 03:51 PM
How to block itemcheck event when i double click in a listView (not click on the checkbox) Bright Sun Microsoft C# .NET 0 28th Jan 2004 04:36 PM
No Double-Click event fired for a ListView when I double click. active Microsoft VB .NET 1 26th Nov 2003 05:44 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:58 AM.