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

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
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,214,649
Messages
6,120,732
Members
448,987
Latest member
marion_davis

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