Select named range with VBA?

Mr2017

Well-known Member
Joined
Nov 28, 2016
Messages
634
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Hi

I have a tab where I'd like to refer to the cells using named ranges instead of absolute references.

So, for example, I currently use this to select cell I8 then clear it, but

VBA Code:
'clear cell I8
'Range("I8").Select
Selection.ClearContents

But I'd like to use this instead (assuming that the range for that cell is simply called 'First_Cell') I'd prefer to use a named range in case someone inserts a column, which would mean that the code would then delete the data in the wrong cell.

However, this code didn't work, as expected. Does anyone know the easiest way to modify this? TIA

VBA Code:
'clear cell I8 
Range.First_Cell.Select
Selection.ClearContents
 

Some videos you may like

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
36,463
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2010
Platform
  1. Windows
  2. MacOS
There is no need to select it - you can just use:

Code:
Range("First_Cell").ClearContents
 

Watch MrExcel Video

Forum statistics

Threads
1,127,610
Messages
5,625,797
Members
416,138
Latest member
Pizzaman22

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