Can i use a named range as just the column in a macro

tonywatsonhelp

Well-known Member
Joined
Feb 24, 2014
Messages
3,194
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
Hi everyone,

Its a long story why so i wont get into it,
but Heres what i want to do

I have a named range called "Total_Names"

I have a macro that does lots of things and one is in the same column as ""Total_Names"
So i was woundering if i could ref "Total_Names" column in my vba code

For example if i was writing it in English it would be something like this:

Column1 = "Total_Names" . column

Range(Column1 & "12") = "Test Data1"

Range(Column1 & "16") = "Test Data2"
end sub

and so if Column1 = Column D then D12 = "Test Data1"

can this be done if so how

Thanks

Tony
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Tony

Short answer, yes.

However you couldn't do it with the code you posted - you would use Cells instead of Range.
VBA Code:
Column1 = Range("Total_Names").Column

Cells(12, Column1) = "Test Data1"

Cells(16, Column1) = "Test Data2"
 
Upvote 0
And thats where i was going wrong! trying to do it with range
Thanks very much this is going to be so helpfull
Tony
 
Upvote 0

Forum statistics

Threads
1,215,391
Messages
6,124,678
Members
449,179
Latest member
fcarfagna

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