Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How to calculate number of occurencies of a specific number number | Excel Discussion (Misc queries) | |||
Fill Right Variable Number of Columns, then Calculate Using Offset | Excel Programming | |||
New columns won't calculate | Excel Discussion (Misc queries) | |||
calculate best 4 out of 6 columns | Excel Worksheet Functions | |||
How can I calculate columns? | Excel Worksheet Functions |