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

ResolvedVersion 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:

Hide columns in an Excel 2010 Worksheet

If you don’t want part of the Excel worksheet to be visible or when you don’t want certain data to appear in print outs, then a simple solution is to temporarily hide a column or multiple columns.

Hiding a single column:

1)Right click on the column header of the column you want to hide (this is the grey bar along the top edge of the worksheet)
2)Choose Hide from the menu
3)This column will now be hidden from view

Hide more than one column:

1)In the column header drag select to highlight the columns you want hidden
2)Right click and choose Hide from the menu

View all Excel hints and tips

Connect with us:

0207 987 3777

Call for assistance

Request Callback

We will call you back

Server loaded in 0.09 secs.