End If without Block If

claudehollett

Board Regular
Joined
Dec 11, 2003
Messages
89
I have written the following code to loop through all sheets except "Master" setting all cell widths and heights to equal those of the "Master" sheet. It produces a compile error saying "End If without Block If". can somepme tell me what is wrong?

Code:
Sub SetAllCellWidthsHeightstoMaster()

    Dim Master As Worksheet
    Set Master = ThisWorkbook.Worksheets("Master")
    Dim ws As Worksheet
    
    For Each Worksheet In ThisWorkbook.Worksheets
        With ws
            If .Name <> "Master" Then
                For c = 1 To 52
                    ActiveSheet.Columns(c).ColumnWidth = Master.Columns(c).ColumnWidth
                Next
                For r = 1 To 3
                    ActiveSheet.Rows(r).RowHeight = Master.Rows(r).RowHeight
            End If
    Next
    
End Sub

EDIT - Added code tags - Moderator
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.

patrickmuldoon99

Active Member
Joined
Jun 27, 2006
Messages
345
You're also missing a next here:

For r = 1 To 3
ActiveSheet.Rows(r).RowHeight = Master.Rows(r).RowHeight
End If
 

Forum statistics

Threads
1,136,272
Messages
5,674,749
Members
419,525
Latest member
helensesc

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
Top