Offset code

ChristineJ

Well-known Member
Joined
May 18, 2009
Messages
771
Office Version
  1. 365
Platform
  1. Windows
The code below is part of code I have for entering text in a pop-up box. ColumnC is a named range. When a cell in the range is selected, the text in the strMsg appears in a pop-up box. That works fine.

Code:
Case Range("ColumnC").Column
                    If Range("A37").Value = 1 Then
                        strMsg = "This is test 1." & vbCr & "This is test 2." & vbCr & "ANSWER: 55"
                    End If

I'd like to replace the "55" in the answer and instead have it automatically show the value in the cell 18 columns to the right in the same row as the cell that is selected.

Thanks.
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Try

Code:
Case Range("ColumnC").Column
    If Range("A37").Value = 1 Then
        strMsg = "This is test 1." & vbCr & "This is test 2." & vbCr & "ANSWER: " & ActiveCell.Offset(, 18).Value
    End If
 
Upvote 0

Forum statistics

Threads
1,223,171
Messages
6,170,479
Members
452,332
Latest member
The2ndQuest

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