98.7% Of all customers recommend us, we're so confident about our results we publish all reviews and stats
View Live Stats View ReviewsForum home » Delegate support and help forum » Microsoft Excel VBA Training and help » ","
","
Resolved · 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
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 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
Any suggestions, questions or comments? Please post in the Improve the forum thread. |
Excel tip:Formst Excel to display leading zeroesSelect the cells that you want to have displaying leading zeroes. |