How to disable wrap text permanently?

man

Board Regular
Joined
Jul 26, 2010
Messages
78
Office Version
  1. 2021
Platform
  1. Windows
Sometimes I type text in a cell and the [Wrap Text] button automatic pressed down. (screenshot 1)

I do not want the [Wrap Text] button to be pressed down permanently. I want it to look like screenshot 2 permanently

How to disable wrap text permanently? Thanks.

screenshot 1
wrap text button is press down (i do not want).PNG


screenshot 2
wrap text button is not press down (i want it).PNG
 
View Code -> Paste the code in the editor.
 
Upvote 0

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Go back to your sheet, try pasting stuff in Column A and see if it's undo your wrap-text.
 
Upvote 0
Go back to your sheet, try pasting stuff in Column A and see if it's undo your wrap-text.
I tried pasting stuff in Column A and it works to undo wrap text in Column A. Column B and other columns still have the same auto Wrap Text problem after pasting text. How to make your solution work for the whole sheet? (note: the sheet shown in this thread are examples, in my real sheet I need to paste in many columns, and my real sheet already has old info pasted in many cells)
 
Upvote 0
First, run this code one time to undo all of the existing wrap text:
VBA Code:
Sub UndoWrapText()
    Dim ws As Worksheet
    Dim rng As Range
    
    Application.ScreenUpdating = False
    
    For Each ws In ThisWorkbook.Worksheets
        For Each rng In ws.UsedRange
            rng.WrapText = False
        Next rng
    Next ws
    
    Application.ScreenUpdating = True
End Sub

Replace the prior code with this to apply to all columns.
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    Dim rng As Range
    Application.EnableEvents = False
    If Not Intersect(Target, Me.UsedRange) Is Nothing Then
        For Each rng In Target
            rng.WrapText = False
        Next rng
    End If
    Application.EnableEvents = True
End Sub
 
  • Like
Reactions: man
Upvote 0
I tried pasting stuff in Column A and it works to undo wrap text in Column A. Column B and other columns still have the same auto Wrap Text problem after pasting text. How to make your solution work for the whole sheet? (note: the sheet shown in this thread are examples, in my real sheet I need to paste in many columns, and my real sheet already has old info pasted in many cells)

If all you're doing is copy & pasting text information into a cell, there are better applications suited for this task. Excel would be the last option I would consider for this kind of task. I very much agree with Alex's comment earlier. You are using the wrong tool for the job. OneNote has already been mentioned, Notepad++ is another option.
 
Upvote 0
First, run this code one time to undo all of the existing wrap text:
Code:
Sub UndoWrapText()
Dim ws As Worksheet
Dim rng As Range

Application.ScreenUpdating = False

For Each ws In ThisWorkbook.Worksheets
For Each rng In ws.UsedRange
rng.WrapText = False
Next rng
Next ws

Application.ScreenUpdating = True
End Sub
I right click the sheet name>view code then pasted the above code in the editor then press F5 is it correct? Will it apply to all sheets in the workbook?

----------

I then delete the above code and then replace with this below code correct?

Replace the prior code with this to apply to all columns.
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng As Range
Application.EnableEvents = False
If Not Intersect(Target, Me.UsedRange) Is Nothing Then
For Each rng In Target
rng.WrapText = False
Next rng
End If
Application.EnableEvents = True
End Sub

------

After finishing the steps above I then try copy text and paste into excel cell.
 
Upvote 0
If all you're doing is copy & pasting text information into a cell, there are better applications suited for this task. Excel would be the last option I would consider for this kind of task. I very much agree with Alex's comment earlier. You are using the wrong tool for the job. OneNote has already been mentioned, Notepad++ is another option.
I did not know OneNote more than 10 years ago, I have use excel for more than 10 years ago to store info so there are many text in excel already. It works fine for me because I find it neater that all info are in a cell so it does not mess with other info in other cells or sheets. Notepad++ can store all same subject text in a .txt file but not suitable to store different subjects in a same .txt file, for example now I want to record a "chicken soup recipe" text and record a "vacuum cleaner cleaning instructions" text, I would need two .txt file to separate different types of info.
 
Upvote 0
I right click the sheet name>view code then pasted the above code in the editor then press F5 is it correct? Will it apply to all sheets in the workbook?
Yes. The first code will apply to all worksheets. For the second one to work on all sheets, you'd need to right-click and insert that code to each individual sheet code.

I then delete the above code and then replace with this below code correct?
Yes.

After finishing the steps above I then try copy text and paste into excel cell.
Yes.
 
  • Like
Reactions: man
Upvote 0
Yes. The first code will apply to all worksheets. For the second one to work on all sheets, you'd need to right-click and insert that code to each individual sheet code.


Yes.


Yes.
Your solution works. Thanks.

How do I save it so I do not need to repeat the steps to insert code? I click save button then I see this screenshot and not sure what to do
i click save.PNG
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,177
Members
453,021
Latest member
Justyna P

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