VBA: Enable wrap text on multiple sheets

KGee

Well-known Member
Joined
Nov 26, 2008
Messages
539
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
The IF statement below was part of a larger macro and used to enable the wrap text option when it was run from Sheet2.
Code:
If ActiveSheet.Name = "Sheet2" Then
    Range(Range("M22"), Range("M22").End(xlDown)).WrapText = True
End If

We have since added more worksheets to our file and would like to run the entire macro from Sheet1 and have it enable the wrap text option on multiple sheets. I tried using the lines below but it doesn't work. Everything else I tried failed in the debugger.
Code:
Sheets("Sheet2").Range("M22").End(xlDown).WrapText = True
Sheets("Sheet4").Range("C20").End(xlDown).WrapText = True
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
One option
Code:
With Sheets("Sheet2")
   .Range("M22", .Range("M22").End(xlDown)).WrapText = True
End With
How many sheets are you looking to run this on?
 
Upvote 0
To capture these user comments, two so far but there are currently six sheets in the workbook and there are other formatting type changes specific to each sheet that need to be applied so I am following the same approach. Thanks!
 
Last edited:
Upvote 0
Glad to help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,182
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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