How to use macro to replace specific rows

fauzan_lesmana

New Member
Joined
Sep 26, 2011
Messages
2
Dear Excel Expert,

Please help me using Macro, I want to replace the height of odd rows like row 1 , row 3, row 5, etc without making any replacement to even rows.
Thank you.
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Welcome to MrExcel.

Here's an example that you may be able to adapt:

Code:
Sub Test()
    Dim r As Long
    With ActiveSheet
        For r = 1 To 20
            If r Mod 2 = 1 Then
                .Rows(r).RowHeight = 20
            End If
        Next r
    End With
End Sub
 
Upvote 0
Welcome to MrExcel.

Here's an example that you may be able to adapt:

Code:
Sub Test()
    Dim r As Long
    With ActiveSheet
        For r = 1 To 20
            If r Mod 2 = 1 Then
                .Rows(r).RowHeight = 20
            End If
        Next r
    End With
End Sub

Well, thank you Mr. Andrew. This is resolve my problems. I've tried it.:)
 
Upvote 0
Here's an example that you may be able to adapt:

Code:
Sub Test()
    Dim r As Long
    With ActiveSheet
        For r = 1 To 20
            If r Mod 2 = 1 Then
                .Rows(r).RowHeight = 20
            End If
        Next r
    End With
End Sub
You can eliminate the If..Then test and add a Step argument to the For statement to make this a little easier for the OP to modify...

Code:
Sub Test()
    Dim r As Long
        For r = 1 To 20 Step 2
            ActiveSheet.Rows(r).RowHeight = 20
        Next r
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,503
Messages
6,179,136
Members
452,890
Latest member
Nikhil Ramesh

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