VBA Wrap Text For All Active Sheets Problems

bloodmilksky

Board Regular
Joined
Feb 3, 2016
Messages
202
Hi Guys, I hope everyone is well.

I have been using the below to run copy and past information from row 8 to row a1 throughout a workbook and just to try and tidy it up I thought I would try and make everything look nice and tidy. the column and row auto fit code works fine but when i have tried to "wraptext" for all active worksheets it errors. can anyone help please?

Many thanks

jamie

Sub Treat()
Dim WS As Worksheet
For Each WS In Worksheets
If (WS.Name <> "Sheet1") Then
Sheets("Sheet1").Rows("8:8").Copy Destination:=WS.Range("A1")
WS.Select
Selection.Columns("A:A").ColumnWidth = 2.56
Selection.Columns("B:B").ColumnWidth = 10
Selection.Columns("C:C").ColumnWidth = 9.22
Selection.Columns("D:D").ColumnWidth = 20.78
Selection.Columns("E:E").ColumnWidth = 63
Selection.Columns("F:F").ColumnWidth = 46
Selection.Columns("G:G").ColumnWidth = 46
Selection.Columns("H:H").ColumnWidth = 7.11
Selection.Columns("I:I").ColumnWidth = 11.44
WS.Select
With Selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlBottom
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
Columns.EntireColumn.AutoFit
Rows.EntireRow.AutoFit


End With


End Sub
 

Excel Facts

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

Forum statistics

Threads
1,220,965
Messages
6,157,119
Members
451,398
Latest member
rjsteward

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