How to Return Range value to message box

kmbrady

New Member
Joined
Aug 16, 2017
Messages
2
I have a text string stored in a cell that I need to show in a message box

Text is in cell 'e34' on sheet 'Tables'

I have also named cell 'e34' as 'TxT13'

If i refer to the cell as 'e34' this code works

Sub WITO()
If Sheets("Tables").Range("Prmt13") = "True" Then​
msg = Sheets("Tables").Range("e34").Value
MsgBox msg
End If​
End Sub

BUT
If I use the Range Name I get a blank message box

Sub WITO()
If Sheets("Tables").Range("Prmt13") = "True" Then​
msg = Sheets("Tables").Range("TxT13").Value
MsgBox msg
End If​
End Sub

I have attempted several variations but always get a blank message box,
' msg = Worksheets("Tables").Range("TxT13")
' msg = Sheets("Tables").Evaluate("TxT13")
' msg = Sheets("Tables").Range("TxT13").Value

Using the Range name does not return the text value to the message box. If I use the Name Manager to look at all my named ranges, the values are shown.

Suggestions?
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
"TxT13" is not a valid Name. Excel should Autocorrect to "TxT13_"

Adjust your "msg" variable to match.
 
Upvote 0
"TxT13" is not a valid Name. Excel should Autocorrect to "TxT13_"

Adjust your "msg" variable to match.

Thanks for the tip, adding the underline worked.

What is interesting is I'm testing a named Range (Prmt13) for a 'True' value, and it works without the underline at the end.
If Sheets("Tables").Range("Prmt13") = "True" Then ....

Thanks again
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,333
Members
452,636
Latest member
laura12345

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