#1   Report Post  
Posted to microsoft.public.excel.misc
Steph
 
Posts: n/a
Default macros program

I am trying to write a macros program.

How can I get excel to subtract the last numer in a column from the first
number in the same column?

The range is always different
  #2   Report Post  
Posted to microsoft.public.excel.misc
Gary''s Student
 
Posts: n/a
Default macros program

Try this UDF:


Function top2bottom(i As Integer) As Double
Dim top As Double
Dim bot As Double
Dim j As Long
top = 0
bot = 0
top2bottom = 0

If i 255 Then
Exit Function
End If

For j = 1 To 65536
If Application.IsNumber(Cells(j, i)) Then
top = Cells(j, i).Value
Exit For
End If
Next

For j = 65536 To 1 Step -1
If Application.IsNumber(Cells(j, i)) Then
bot = Cells(j, i).Value
Exit For
End If
Next

top2bottom = top - bot

End Function


For column A use =top2bottom(1)
--
Gary''s Student


"Steph" wrote:

I am trying to write a macros program.

How can I get excel to subtract the last numer in a column from the first
number in the same column?

The range is always different

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
Excel crashes while opening excel file imbeddied with macros ct2147 Excel Discussion (Misc queries) 0 December 30th 05 09:05 PM
Need Help Initializing Excel Spreadsheet Program jb999 Excel Discussion (Misc queries) 3 November 2nd 05 11:09 PM
Hyperlink in Excel opens the right program, but can't read file. Katydid Excel Discussion (Misc queries) 0 May 6th 05 04:16 PM
Enabling macros Peter M Excel Discussion (Misc queries) 3 February 7th 05 10:57 PM
Transferring toolbars and macros to other computers Darrell Excel Discussion (Misc queries) 1 January 19th 05 12:21 AM


All times are GMT +1. The time now is 10:03 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"