LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Circular Reference?

I created (created may be a strong word since they really aren't
original) the two small functions shown below so that in my Excel
macros I could determine how far out in a spreadsheet that data
actually can be found. Anyway, open up a new workbook and paste this
into a module. Then go to Sheet1 (which should be blank) and go to any
random cell. Type in =LastCol() and hit enter and notice that the
value displayed in the cell is in fact the index corresponding to the
column number of the farthest right value. What's interesting is that
it's also the index corresponding to the column number of the formula.
Isn't this a circular reference? You cant go into cell A1 and say
=A1*2. So why does this return a value which wouldn't exist without
the formula itself. What I mean is that the answer to the question is
driven by the question itself, or at the very least the location of the
question. Anyway, it doesn't hurt me because I'm using these functions
in code rather than in worksheets (i.e. x = lastrow() and y =
lastcol()). Just a peculiarity that I found interesting.

Function LastCol() As Integer
' LastCol() Returns An Integer Value Corresponding To The Index Of
The Farthest Right Non-Empty Column In A Worksheet
On Error Resume Next
LastCol = Cells.Find("*", [A1], xlValues, , xlByColumns,
xlPrevious).Column
End Function

Function LastRow() As Integer
' LastRow() Returns An Integer Value Corresponding To The Index Of
The Farthest Down Non-Empty Row In A Worksheet
On Error Resume Next
LastRow = Cells.Find("*", [A1], xlValues, , xlByRows,
xlPrevious).Row
End Function

 
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
Circular Reference revdeacon Excel Discussion (Misc queries) 1 April 8th 08 07:17 PM
Is this possible? (Circular reference?) Big UT Fan Excel Discussion (Misc queries) 2 July 11th 07 04:48 PM
Circular Reference nastech Excel Discussion (Misc queries) 1 April 27th 06 12:54 AM
Circular reference help please! [email protected] Excel Discussion (Misc queries) 1 February 9th 06 10:41 AM
Circular reference leon Excel Worksheet Functions 1 November 1st 04 12:45 PM


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

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

About Us

"It's about Microsoft Excel"