Dynamically build call reference

UHsoccer

Well-known Member
Joined
Apr 3, 2002
Messages
1,023
I need to dynamically change the cell reference based on the month of the year that is being requested

Example
Range("G9").Select (is for Dec)
Range("I9").Select (is for Jan)

I need to do something like

if month = "Dec" then var = "G"
if month = "Jan" then var = "I"

How do I use "var" in the Range statement
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Just a word of advice. I would not recomend hard coding a range address reference in a macro. If you ever move formulas or insert colums or rows the macro will mess you up big time.

I would suggets naming the top cell and then using offset references from the name. The name will move if rows or columns are inserted and the macro will continue to perform as expected.


"Think Ahead, Be Prepared"
 
Upvote 0

Forum statistics

Threads
1,214,840
Messages
6,121,895
Members
449,058
Latest member
Guy Boot

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