VBA: Enable wrap text on multiple sheets

KGee

Well-known Member
Joined
Nov 26, 2008
Messages
537
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

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
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,221,310
Messages
6,159,176
Members
451,543
Latest member
cesymcox

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