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…
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…