VBA selection question

Mr930

Well-known Member
Joined
Aug 31, 2006
Messages
585
I have some VBA code where I clear a range. After it clears, the range is still selected. How do I unselect that range in VBA? I know this is simple but I can't find the answer in the help....

thanks
Fred
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Fred

You shouldn't need to select the range in the first place to clear it.

Can you post your code?
 
Upvote 0
The easiest way I can think of is to select a single cell somewhere

activesheet.range("A1").select

HTH
Cal
 
Upvote 0
Fred

You shouldn't need to select the range in the first place to clear it.

Can you post your code?

I created the code by recording a macro:
Sheets("Save").Select
Range("C7:AE1507").Select
Application.CutCopyMode = False
Selection.ClearContents
 
Upvote 0
Fred

Try this.
Code:
Sheets("Save").Range("C7:AE1507").ClearContents
Generally recorded code can do with a tidy up.:)
 
Upvote 0

Forum statistics

Threads
1,215,022
Messages
6,122,716
Members
449,093
Latest member
Mnur

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
Back
Top