Format every fouth row height

MaleNurse

New Member
Joined
Jul 13, 2015
Messages
24
I have a number of large spread- sheets. I need to format the row height of every fourth row to 24.00
I have the macro below which doesn't work. Can anyone fix it please?

Sub Height()
X = 0
Do
X = X + 4
Rows(X).RowHeight = 24
Loop Until X = 1000
End Sub


Thanks Steve..:mad:
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Hi,

the search-engine says:

Code:
Sub Main
for i = 1 to 12 step 4
     rows(i).rowheight = 24 
next i
End Sub

regards
 
Upvote 0
Try this:
Code:
Sub Row_Height()
Application.ScreenUpdating = False
Dim i As Long
    For i = 4 To 1000 Step 4
        Rows(i).RowHeight = 24
    Next
Application.ScreenUpdating = True
End Sub
 
Upvote 0
So you did not like my script?
Change

Code:
For i = 4 To 1000 Step 4

To:
Code:
For i = 5 To 1000 Step 4

It is working now. However, it seems to start at random rows. Can I peg it to Row 5 then every subsequent 4th row will be set at the desired height.
 
Upvote 0
Thank you that works fine. I have a glitch in the spread sheet down at about row 220 but the rest of the script is perfect.. Now I only have to copy it into 23 spread sheets.
Cheers
 
Upvote 0
If you wanted to do all 23 worksheets starting in sheet 1 you could use this script.
And it would do all 23 sheets at one time.
But you may have not liked my script since you ignored all my questions

Code:
Sub Row_Height()
'Modified 11-25-17 5:57 AM EST
Application.ScreenUpdating = False
Dim i As Long
Dim b As Long
    For b = 1 To 23
    
    With Sheets(b)
    For i = 5 To 1000 Step 4
        .Rows(i).RowHeight = 24
    Next
    End With
    Next
Application.ScreenUpdating = True
End Sub
 
Last edited:
Upvote 0
The below will change the height in every worksheet in the workbook where you have data in column A past row 4 in one go rather than looping through the rows one at a time.


Rich (BB code):
Sub OtherRow()
    Dim LR As Long, i As Long
    Dim myRow As Range, mySht As Worksheet
    Application.ScreenUpdating = False

    For Each mySht In ActiveWorkbook.Worksheets

        With mySht
            LR = .Range("A" & Rows.Count).End(xlUp).Row
            If LR > 4 Then
                Set myRow = .Rows(1)
                For i = 5 To LR Step 4
                    Set myRow = Union(myRow, .Rows(i))
                Next i
                myRow.RowHeight = 24
            End If
        End With

    Next
    Application.ScreenUpdating = True
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,231
Messages
6,170,884
Members
452,364
Latest member
springate

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