Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default strange loop problem

Have a trange problem, I have a series of two macros that work perfectly,
except the first time they are called.

The macros are as follows:

Sub fill_right(r, z)

Dim c
c = 5
Dim temp_range

Do While c < 28
temp_range = Range(Cells(r, c), Cells(z - 1, c))
Call find_abs_max(temp_range, z, c, summarysheet)
c = c + 1
Loop

End Sub


which calls:

Sub find_abs_max(read_range, target_row, target_column, target_sheet)
Dim max_range As Single
Dim min_range As Single
Dim abs_min_range As Single

target_sheet.Activate
max_range = Application.WorksheetFunction.Max(read_range)
min_range = Application.WorksheetFunction.Min(read_range)

If min_range < 0 Then
abs_min_range = -1 * min_range
If max_range abs_min_range Then
Cells(target_row, target_column) = max_range
Else
Cells(target_row, target_column) = min_range
End If
Else
Cells(target_row, target_column) = max_range
End If
End Sub

Basically, I am creating a cutom "find absolute maximum" formula and then
inserting the results in the appropriate cells, i.e. the result row columns 5
to 27. Actually having the formula in the result cells won't work as the
refrenced range (r:z) is deleted and repopulated by preceding macros each
time.

I found that the macros work perfectly fine except for the very time they
are called (i.e. cell row r, column 5), in which the result for the absolute
maximum of 4 cells in r5 to r(z-1) each containing the value 30.48 is zero
(which is obviously wrong). The macros work fine on a separate range with
the exact same values, and on each successive range and reslt row used, so I
am a little stumped as to why they are returning zero for the first run.

Would greatly appreciate any insight to this issue.

Jason
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
Problem adding charts using Do-Loop Until loop Chris Bromley[_2_] Excel Programming 2 May 23rd 05 01:31 PM
VBA & API - Strange problem using Philip Excel Programming 0 May 11th 05 09:30 AM
Do Until Loop strange behavior dht[_2_] Excel Programming 2 February 14th 05 03:30 PM
strange problem For Each loop in Treeview Peter Beach Excel Programming 12 August 26th 03 02:46 PM
strange problem For Each loop in Treeview RB Smissaert Excel Programming 0 August 25th 03 07:18 PM


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