PC Review


Reply
Thread Tools Rate Thread

Determining number of columns of 2 different ranges

 
 
filo666
Guest
Posts: n/a
 
      16th Jan 2008
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
 
Reply With Quote
 
 
 
 
papou
Guest
Posts: n/a
 
      16th Jan 2008
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

"filo666" <(E-Mail Removed)> a écrit dans le message de
news: 1B79711D-B343-47A8-B9F6-(E-Mail Removed)...
> 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



 
Reply With Quote
 
Peter T
Guest
Posts: n/a
 
      16th Jan 2008
Dim ra As Range

For Each ra In Selection.Areas
Debug.Print ra.Columns(1).Column
Next

Regards,
Peter T

"filo666" <(E-Mail Removed)> wrote in message
news:1B79711D-B343-47A8-B9F6-(E-Mail Removed)...
> 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



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
determining slide number and object/shape number Candace Microsoft Powerpoint 4 6th May 2008 03:52 PM
Determining number of Ranges Jimmy O Microsoft Excel Programming 12 1st Mar 2008 06:00 PM
determining identical ranges upstate_steve Microsoft Excel Misc 2 23rd Apr 2004 08:00 PM
Determining if two ranges overlap Marky Microsoft Excel Programming 4 18th Feb 2004 09:54 AM
Determining date ranges Philip Townsend Microsoft ASP .NET 0 6th Nov 2003 08:26 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:56 AM.