I'm selecting two separate areas of my worksheet using Ctrl-Click(drag);
a1:a4 and c1:c4
I would like to know how to get the column number 1 for colum "A" and 3 for
colum "C".
pd, I'm not always using the same areas (it could be d1:d56 and g1:g7; and
in this case I want 4 and 7 respectivly).
TIA
papou - 16 Jan 2008 10:08 GMT
Hi
May be this will do:
Dim colOne As Integer, colTwo As Integer
colOne = Cells(1, Mid(Left(Selection.Address, 2), 2, 1)).Column
colTwo = Cells(1, Left(Right(Selection.Address, 3), 1)).Column
MsgBox "First column = " & colOne & vbLf _
& "Second column = " & colTwo
HTH
Cordially
Pascal
> I'm selecting two separate areas of my worksheet using Ctrl-Click(drag);
> a1:a4 and c1:c4
[quoted text clipped - 7 lines]
>
> TIA
Peter T - 16 Jan 2008 10:09 GMT
Dim ra As Range
For Each ra In Selection.Areas
Debug.Print ra.Columns(1).Column
Next
Regards,
Peter T
> I'm selecting two separate areas of my worksheet using Ctrl-Click(drag);
> a1:a4 and c1:c4
[quoted text clipped - 5 lines]
>
> TIA