cell alignment

claudehollett

Board Regular
Joined
Dec 11, 2003
Messages
89
I need to cycle through each worksheet in a workbook setting selected cell alignments (verticle & horizontal) on each sheet to match cell alignments for the same cell address in a sheet called "Master". The cell alignment will differ for each cell in the selection. Can you help, please. Claude
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
If either there are no formulas in the cells, or the formulas on the Master are the same as on the corresonding cells on te other worksheets, then you could highlight the cells you need formatting on the Master, then click on the Format Painter, then click on the first cell of the required range on the first worksheet. Repeat the process for each worksheet. Done.
 
Upvote 0
Here is code that will loop through the worksheets in the active workbook and paste formats...

Code:
Public Sub my_copy_format()
On Error Resume Next

    Const strRange As String = "A1:G10"  'modify range as needed
    Const strMaster As String = "Master" 'name of master worksheet
    
    Application.ScreenUpdating = False
    
    'determine current sheet/selection
    Set curSel = Selection
    Set curWs = ActiveSheet

    'copy formats from master worksheet
    Worksheets(strMaster).Activate
    Range(strRange).Select
    Application.CutCopyMode = False
    Selection.Copy
    
    'loop through each worksheet and paste formats
    For Each ws In ActiveWorkbook.Worksheets
        If ws.Name <> strMaster Then
            ws.Activate
            Set wsSel = Selection
            Range(strRange).Select
            Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
                SkipBlanks:=False, Transpose:=False
            wsSel.Select
        End If
    Next ws
    
    'restore workbook to original sheet/selection
    curWs.Activate
    curSel.Select
    Application.ScreenUpdating = True
    
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,996
Messages
6,122,636
Members
449,092
Latest member
bsb1122

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