Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Problem adding charts using Do-Loop Until loop | Excel Programming | |||
VBA & API - Strange problem using | Excel Programming | |||
Do Until Loop strange behavior | Excel Programming | |||
strange problem For Each loop in Treeview | Excel Programming | |||
strange problem For Each loop in Treeview | Excel Programming |