PC Review


Reply
Thread Tools Rate Thread

Deleting a range after selecting a sheet

 
 
MichaelJohnson168@hotmail.com
Guest
Posts: n/a
 
      25th Feb 2008
I have a button on a worksheet that when pressed is supposed to:

1. Go to another worksheet in the same workbook
2. Select a range of cells in that worksheet
3. Delete the selected range of cells

However I am getting the following error message:

"Select method of Range class failed" when the code executes --
Range(selRange).Select--

Can someone inform me of how I can fix this? Thanks in advance


The code segemnt is below

------------------------------------
selEnd = readRow - 1

selRange = "A" + Trim(Str(selBegin))

selRange = selRange + ":" + "F" + Trim(Str(selEnd))

Sheets("Shared Emp Master Sheet").Select

Range(selRange).Select <- ERROR OCCURS HERE

Selection.Delete Shift:=xlUp
------------------------------------
 
Reply With Quote
 
 
 
 
paul.robinson@it-tallaght.ie
Guest
Posts: n/a
 
      25th Feb 2008
Hi
Replace Str with Cstr
and you need
Sheets("Shared Emp Master Sheet").Activate
Range(selRange).Select
Selection.Delete Shift:=xlUp

better still do
Sheets("Shared Emp Master Sheet").Range(selRange).Delete Shift:=xlUp

regards
Paul




On Feb 25, 3:27*pm, MichaelJohnson...@hotmail.com wrote:
> *I have a button on a worksheet that when pressed is supposed to:
>
> 1. Go to another worksheet in the same workbook
> 2. Select a range of cells in that worksheet
> 3. Delete the selected range of cells
>
> However I am getting the following error message:
>
> "Select method of Range class failed" when the code executes --
> Range(selRange).Select--
>
> Can someone inform me of how I can fix this? Thanks in advance
>
> The code segemnt is below
>
> ------------------------------------
> selEnd = readRow - 1
>
> selRange = "A" + Trim(Str(selBegin))
>
> selRange = selRange + ":" + "F" + Trim(Str(selEnd))
>
> Sheets("Shared Emp Master Sheet").Select
>
> Range(selRange).Select * * * *<- ERROR OCCURS HERE
>
> Selection.Delete Shift:=xlUp
> ------------------------------------


 
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
Selecting Range Based on Cell Content then Copy/Paste to New Sheet,Looping pwk Microsoft Excel Programming 2 26th Sep 2009 02:18 PM
RE: Subscript out of range error - selecting a sheet Joel Microsoft Excel Programming 1 3rd Aug 2009 12:35 AM
Copy paste without selecting sheet or range Richard Microsoft Excel Programming 2 23rd May 2008 12:22 PM
Selecting and deleting named range based on cell value Rich Kniatt Microsoft Excel Programming 1 6th Apr 2006 08:04 PM
Selecting Range in non-active sheet mboursnell@gmail.com Microsoft Excel Programming 0 27th Mar 2006 01:44 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:23 PM.