Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 846
Default Calculate the number of Columns apart

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Calculate the number of Columns apart

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" wrote in message
...
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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Calculate the number of Columns apart

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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to calculate number of occurencies of a specific number number Stefan Excel Discussion (Misc queries) 4 September 8th 08 08:33 AM
Fill Right Variable Number of Columns, then Calculate Using Offset ryguy7272 Excel Programming 6 October 25th 07 06:16 PM
New columns won't calculate glitterbug99 Excel Discussion (Misc queries) 2 September 3rd 07 01:54 PM
calculate best 4 out of 6 columns MSandy Excel Worksheet Functions 2 March 23rd 06 12:33 AM
How can I calculate columns? Ninabean Excel Worksheet Functions 1 August 30th 05 03:15 PM


All times are GMT +1. The time now is 07:58 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"