putting reference in quotations

Noz2k

Well-known Member
Joined
Mar 15, 2011
Messages
693
Quick question I think.

but I have some code like

Code:
 N = textbox1 & textbox2
X = N & " Or " textbox3

so say textbox1 = A, textbox2 = B and textbox3 = C

X would equal AB Or C

but I need it to be X = "AB" Or "C"

if I try to put quotations marks in I get

X = "N" Or "textbox3"

ANy idea how I do this?
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
When inserting double quotations I use the ASCII character chr(34).

Test this code, apologies for not declaring the variables:

Code:
[COLOR=darkblue]Sub[/COLOR] test()
   
   textbox1 = "A"
   textbox2 = "B"
   textbox3 = "C"
   
   n = Chr(34) & textbox1 & textbox2 & Chr(34)
   Debug.Print n
   
   x = n & " or " & Chr(34) & textbox3 & Chr(34)
   Debug.Print x
   
[COLOR=darkblue]End[/COLOR] [COLOR=darkblue]Sub[/COLOR]
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,283
Members
452,902
Latest member
Knuddeluff

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