How do I create or use a relative cell reference (and Sheet

Cosmos75

Active Member
Joined
Feb 28, 2002
Messages
359
How do I create a relative reference in VBA?

In Sheet1, I have a cell (A1) that changes its value based on a listbox in the sheet.

In Sheet2, I have a list of values.

The list box in Sheet1 tells me which column to look in Sheet2 on the third row.

If A1 = 4, I want to create a VBA statement that show a message box says, “The value is 10”, where the value in Row 3, Column 4 in Sheet2 is 10.

Anybody know how to do this?

I’ve tried

WhichColumm = Range(“A1”).Value
Range(“ ‘Sheet2’A” & WhichColumm).value

Which doesn’t work.

AND

WhichColumm = Range(“A1”).Value
Cells(3, WhichColumm).value

Which works, but it looks at Sheet1 and I don’t know how to get it to look at Sheet2…
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"

Forum statistics

Threads
1,214,983
Messages
6,122,588
Members
449,089
Latest member
Motoracer88

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