Multiple Cell Selection Coordinates

EliasEMS

New Member
Joined
Mar 4, 2013
Messages
5
Hello,

How can I get coordinates for multiple selected cells? I know it is possible with one cell selected by using "selection.address". How would it work if I had more than one cell selected?

Thank you!
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
The Selection.Address Property Works Even If The Selection Is Multiple Even If You Press Ctrl And Highlight Multiple Ranges!
ZAX
 
Upvote 0
The Selection.Address Property Works Even If The Selection Is Multiple Even If You Press Ctrl And Highlight Multiple Ranges!
ZAX
Just to add to ZAX's comment... the Address property can take optional arguments, so I would recommend you use Selection.Address(0,0) in order to get rid of the $ signs in its output. Also, the string argument for Range is limited to 255 characters, so doing this will also allow more addresses overall to be returned to you.
 
Upvote 0
Thank you guys! That works perfectly. So now I get multiple coordinates, how do i refer to each individually?

For instance, I will run a macro for each coordinate, how do I take only the first coordinate returned, and then the second?

Thank you very much!
 
Upvote 0
Thank you! That works perfectly. So now I get multiple coordinates, how do i refer to each individually?

For instance, I will run a macro for each coordinate, how do I take only the first coordinate returned, and then the second?

Thank you very much!
 
Upvote 0
In that case, you don't need the address property of selection.
You need to loop through selection, then you can do whatever you want with each cell in selection.

Code:
For Each c In Selection
    MsgBox c.Address
Next c
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,248
Members
452,623
Latest member
cliftonhandyman

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