Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Deleting a range after selecting a sheet

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
------------------------------------
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 789
Default Deleting a range after selecting a sheet

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, 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
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
More Selecting and Deleting bodhisatvaofboogie Excel Programming 2 June 15th 06 03:37 PM
Selecting AND Deleting bodhisatvaofboogie Excel Discussion (Misc queries) 11 May 24th 06 01:18 PM
Selecting and deleting named range based on cell value Rich Kniatt[_5_] Excel Programming 1 April 6th 06 08:04 PM
Selecting Range in non-active sheet [email protected] Excel Programming 0 March 27th 06 01:44 PM
sub for deleting data on a sheet in a range Buddy Lee Excel Programming 3 September 20th 05 09:14 PM


All times are GMT +1. The time now is 06:47 PM.

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"