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

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,092
Messages
5,835,344
Members
430,351
Latest member
ddalton

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