Excel VBA Select Method - de-selecting pasted cells

KerryFSA

New Member
Joined
Dec 5, 2018
Messages
49
I have a 100x100 spreadsheet to which I paste data from another workbook using a macro. After the paste has been carried out, the entire recipient WS is shaded (selected). I would like to select a single cell in this WS so that the entire WS is not left selected. Here's the code I have tried, for which I get the error "Select method of range class failed" (1004). ("Sh" is a string that id's the sheet to be used in WB B; e.g. Sheet6.)

Rng1.Copy ' from WB A
Rng1P.PasteSpecial xlPasteValuesAndNumberFormats 'to WB B

Workbooks("WB B.xlsm").Sheets(Sh).Range("T4").Select
Application.CutCopyMode = False

Without the Select statement, the macro works just fine.
Even if I use something like:
Workbooks("WB B.xlsm").Sheets(Sh).Range("T4")=1

the macro will place a 1 in T4, but the whole sheet is still highlighted.
Is there another way to unselect the cells that have been pasted into WB B?

Thanks for your help, from a newbie.
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.

mumps

Well-known Member
Joined
Apr 11, 2012
Messages
10,306
You cannot select a cell on any sheet unless it is the active sheet so you will have to do something like this:
Code:
Workbooks("WB B.xlsm").Sheets(Sh).Activate
Range("A1").Select
 

KerryFSA

New Member
Joined
Dec 5, 2018
Messages
49
You cannot select a cell on any sheet unless it is the active sheet so you will have to do something like this:
Code:
Workbooks("WB B.xlsm").Sheets(Sh).Activate
Range("A1").Select

Thank you Mumps. Worked well, of course.
Keep warm.
 

Watch MrExcel Video

Forum statistics

Threads
1,129,752
Messages
5,638,162
Members
417,011
Latest member
Amaden95

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top