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…
 

Some videos you may like

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce

Watch MrExcel Video

Forum statistics

Threads
1,122,511
Messages
5,596,576
Members
414,079
Latest member
Frills

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