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

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,304
Office Version
  1. 365
Platform
  1. Windows
Fred

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

Can you post your code?
 

Cbrine

Well-known Member
Joined
Dec 2, 2003
Messages
3,196
The easiest way I can think of is to select a single cell somewhere

activesheet.range("A1").select

HTH
Cal
 

Mr930

Well-known Member
Joined
Aug 31, 2006
Messages
585
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
 

njimack

Well-known Member
Joined
Jun 17, 2005
Messages
7,764

ADVERTISEMENT

Easy answer - don't select the range. Use
Range("A1").Clearcontents
 

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,304
Office Version
  1. 365
Platform
  1. Windows
Fred

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

Forum statistics

Threads
1,141,624
Messages
5,707,466
Members
421,510
Latest member
haroonstr

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