Proper way to write a string?

g48dd

Board Regular
Joined
Jan 12, 2009
Messages
101
Excel 2003: I am not sure if you call it a string or an array or if they are one and the same but I have code that has many mmmm I think you call them elements?
Code:
"A12,A16,A35,A38,A69,A72,A103,A106,A137,A140,A172,A175,A207,A210,A242,A245,A277,A280,A311,A314,A346,A349,A381,A384,A416,A425,A453,A456,A488,A491,A532,A526,A558,A561,A593,A596,A628,A631,A663,A667,A686,A690,A709,A713,A732,A756,A759,A791,A794,A826,A830"

If I use the ENTER KEY to make this wrap in the CODE WINDOW. Look above you can see my string is all in one big long string lol OK well that is hard to work with. So I placed my curser at the end of one the commas and hit ENTER to wrap the string, but I get an error message that is telling me that I need to enclose my argument with parentheses even though it is, it is just that the line is broken with ENTER /RETURN KEY. How do I work around this.
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
To write a long string over several code lines, you need to divide it into separate strings enclosed by double quotes, concatenate them and use the line continuation character, like this:
Code:
    Dim s As String
    
    s = "A12,A16,A35,A38,A69,A72,A103,A106,A137,A140,A172,A175,A207," & _
        "A210,A242,A245,A277,A280,A311,A314,A346,A349,A381,A384,A416," & _
        "A425,A453,A456,A488,A491,A532,A526,A558,A561,A593,A596,A628," & _
        "A631,A663,A667,A686,A690,A709,A713,A732,A756,A759,A791,A794,A826,A830"
 
Upvote 0
Thank you, rather than copy what you wrote I typed it in myself, hopefully that will help me remember.

Ken
 
Upvote 0

Similar threads

Forum statistics

Threads
1,224,559
Messages
6,179,517
Members
452,921
Latest member
BBQKING

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