ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Selection.Item Query (https://www.excelbanter.com/excel-programming/391291-selection-item-query.html)

[email protected]

Selection.Item Query
 
I'm using a macro to allow a user to design a form, part of the macro
is thus:

sLeft = Selection.Item(1).Address
sRight = Selection.Item(Selection.Count).Address
iTotalcells = Selection.Count
sRange = sLeft + ":" + sRight

What I need to do is work out the x and y coordinates of the upper
left cell that the user is selecting, so "A1" would be x =1 and y =1
while "C6" would be x = 3 and y = 6 and so on.

How can I do that?

Thanks for any assistance.


NickHK

Selection.Item Query
 
Range("a1").Row
Range("a1").column

NickHK

wrote in message
oups.com...
I'm using a macro to allow a user to design a form, part of the macro
is thus:

sLeft = Selection.Item(1).Address
sRight = Selection.Item(Selection.Count).Address
iTotalcells = Selection.Count
sRange = sLeft + ":" + sRight

What I need to do is work out the x and y coordinates of the upper
left cell that the user is selecting, so "A1" would be x =1 and y =1
while "C6" would be x = 3 and y = 6 and so on.

How can I do that?

Thanks for any assistance.




[email protected]

Selection.Item Query
 
Thanks, that solved my problem.



Tom Ogilvy

Selection.Item Query
 
Why do you build that formula manuall

sLeft = Selection.Item(1).Address
sRight = Selection.Item(Selection.Count).Address
iTotalcells = Selection.Count
sRange = sLeft + ":" + sRight

could be replaced with


sRange = Selection.Address

You are using a fairly advanced technique to break out information which you
reassemble back to the original information.

to further illustrate.

if selection.Areas.count = 1 then
yTop = selection(1).Row
xLeft = selection(1).coluimn
yBottom = selection(selection.count).Row
xRight = selection(selection.count).column
end if

--
Regards,
Tom Ogilvy


" wrote:

Thanks, that solved my problem.





All times are GMT +1. The time now is 02:49 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com