Only 1 loop working?

vbaNewby

Board Regular
Joined
Jan 26, 2011
Messages
138
Code:
'Find max 
    Sheets("Sheet2").Select
    largestNum = Application.Max(Range("F13:Z22")) 
    largestNum2 = Application.Max(Range("F24:Z32")) 
    largestNum3 = Application.Max(Range("G39:Z48")) 
    theLargest = Application.Max(largestNum, largestNum2, largestNum3)
    
    MsgBox largestNum
    MsgBox largestNum2
    MsgBox largestNum3
    MsgBox theLargest
    
    numDigits = Len(Fix(theLargest))
    MsgBox numDigits
    If numDigits >= 5 & numDigits <= 7 Then
        For Each r In Range("F13:Z20") 
                r = r / 1000
        Next
        For Each r2 In Range("F24:Z31") 
                r2 = r2 / 1000
        Next
        For Each r3 In Range("G39:Z48")
                r3 = r3 / 1000
        Next
    End If
All my cells are formatted the same. The only range that is dividing by what I want is r3. r2 and r1 do not divide at all. Haven't a clue why.

Assume numDigits returns 6....

Rather confused on this one.

Thanks in advance.
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
No thoughts on this? I put some output statments and it looks like each cell is being traversed in the for loop but for some reason the data is being divided by 1000. Strange how only the third loop works.
 
Upvote 0

Forum statistics

Threads
1,224,603
Messages
6,179,853
Members
452,948
Latest member
UsmanAli786

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top