Deleting a range after selecting a sheet

M

MichaelJohnson168

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
------------------------------------
 
P

paul.robinson

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top