Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

Forum home » Delegate support and help forum » Microsoft Excel VBA Training and help » ","

","

resolvedResolved · Medium Priority · Version 2007

Mark has attended:
Excel VBA Advanced course

","

Hello,

I have come across this piece of code. What does the & "," & mean and do?


strRange = Target.Cells.Address & "," & Target.Cells.EntireColumn.Address & "," & Target.Cells.EntireRow.Address


Regards
Mark

Edited on Sun 12 Aug 2012, 13:04

RE: ","

Hello Mark,

Hope you enjoyed your Microsoft Excel VBA Advanced course with Best STL.

Thank you for your question regarding what the & "," & means in the code.

To join data together in Excel is known as 'concatenation'. So, in the example you have provided, the code joins together cells.address to entirecolumn.address to entirerow.address with commas separating each item.

Another example using the CONCATENATION function in Excel would be as follows:

Cell A1 contains the heading First Name
Cell A2 contains the heading Last Name
Cell B1 contains the name Mary
Cell B2 contains the name Smith

You want to place both names into one cell.

In cell C2 insert this formula:

=CONCATENATION(A2,B2)

Cell C2 will now show MarySmith (no spaces)

Edit the formula to add a space using &" "&

=CONCATENATION(A2&" "&B2)

Cell C2 will now show Mary Smith



I hope this resolves your question. If it has, please mark this question as resolved.

If you require further assistance, please reply to this post. Or perhaps you have another Microsoft Office question?

Have a great day.
Regards,

Rodney
Microsoft Office Specialist Trainer

RE: ","

Hello Rodney,

Thank you for you answer . It explains the & " "& .

Do you know why &" ," & was used and not just & " " & ?

Regards
Mark

RE: ","

Hello Mark,

Who knows why the code uses a comma and no spaces. You would have to view the result after running the code to see what it does. You will then know why the code does what it does.

I hope this resolves your question. If it has, please mark this question as resolved.

If you require further assistance, please reply to this post. Or perhaps you have another Microsoft Office question?

Have a great day.
Regards,

Rodney
Microsoft Office Specialist Trainer

 

Training courses

 

Training information:

Welcome. Please choose your application (eg. Excel) and then post your question.

Our Microsoft Qualified trainers will then respond within 24 hours (working days).

Frequently Asked Questions
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.


 

Excel tip:

Formst Excel to display leading zeroes

Select the cells that you want to have displaying leading zeroes.

From the 'Format' menu select 'Cells' (Or Right-click on the selected range and and select 'Format Cells').

In the 'Number' tab click on 'Custom' in the 'Category' window.

In the 'Type:' box enter zeroes that correspond to the size of the required number (eg 5 zeroes).

Click OK.

When you enter numbers into these cells, leading zeroes will be displayed.

eg 123 = 00123

View all Excel hints and tips


Server loaded in 0.08 secs.