PC Review


Reply
Thread Tools Rate Thread

Calculate the number of Columns apart

 
 
Brad
Guest
Posts: n/a
 
      29th Apr 2009
Thanks for taking the time to read my question.

I have a user form that the user enters cell range info by clicking on the
control that lets you click on a cell and it puts the range in the field (lot
of native excel dialog boxes are like this when making charts)

I have 2 fields that have range info in them, and I'd like to know how I can
calculate the number of columns between them using the info from the form.

For example Field1 = $A$5, Field2 = $F$5. So the difference would be 5.

I hope this makes sense.

Thanks again,
Brad
 
Reply With Quote
 
 
 
 
Rick Rothstein
Guest
Posts: n/a
 
      29th Apr 2009
I'm not sure why your answer is not either 4 or 6 as opposed to 5, but if
that is the answer you want...

Difference = Range(Field1, Field2).Columns.Count - 1

--
Rick (MVP - Excel)


"Brad" <(E-Mail Removed)> wrote in message
news:B908D902-C142-4CBE-8879-(E-Mail Removed)...
> Thanks for taking the time to read my question.
>
> I have a user form that the user enters cell range info by clicking on the
> control that lets you click on a cell and it puts the range in the field
> (lot
> of native excel dialog boxes are like this when making charts)
>
> I have 2 fields that have range info in them, and I'd like to know how I
> can
> calculate the number of columns between them using the info from the form.
>
> For example Field1 = $A$5, Field2 = $F$5. So the difference would be 5.
>
> I hope this makes sense.
>
> Thanks again,
> Brad


 
Reply With Quote
 
Jacob Skaria
Guest
Posts: n/a
 
      29th Apr 2009
Use the .Column property as below

Sub Mac()

Dim fld1, fld2 As Range

Set fld1 = Range("A5")
Set fld2 = Range("F5")

MsgBox fld2.Column - fld1.Column

End Sub

--
If this post helps click Yes
---------------
Jacob Skaria


"Brad" wrote:

> Thanks for taking the time to read my question.
>
> I have a user form that the user enters cell range info by clicking on the
> control that lets you click on a cell and it puts the range in the field (lot
> of native excel dialog boxes are like this when making charts)
>
> I have 2 fields that have range info in them, and I'd like to know how I can
> calculate the number of columns between them using the info from the form.
>
> For example Field1 = $A$5, Field2 = $F$5. So the difference would be 5.
>
> I hope this makes sense.
>
> Thanks again,
> Brad

 
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
select range in column, calculate on range plus 3 columns, output inrange plus 7 columns ppeer Microsoft Excel Programming 8 11th Feb 2010 09:14 PM
How to calculate number of occurencies of a specific number number Stefan Microsoft Excel Misc 4 8th Sep 2008 08:33 AM
Fill Right Variable Number of Columns, then Calculate Using Offset =?Utf-8?B?cnlndXk3Mjcy?= Microsoft Excel Programming 6 25th Oct 2007 06:16 PM
How can I calculate columns? =?Utf-8?B?TmluYWJlYW4=?= Microsoft Excel Worksheet Functions 1 30th Aug 2005 03:15 PM
Need more columns! How to exceed default limit for number of columns per worksheet sallyember Microsoft Excel Misc 1 17th May 2004 03:42 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:37 PM.