Column width auto as per data in cell

needhelp2

Active Member
Joined
Apr 19, 2011
Messages
250
Hi All,


I need to know how i can set Column width auto as per data in cell?
Mean if enter data in cell its width will auto max as per need of data.



Thanks
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Try this in the Worksheet Code Module

Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Cells.Columns("D:D").AutoFit
End Sub

Works on column D. if you want it to work on all columns, get rid of the ("D:D") part.
 
Upvote 0
Glad it worked and thanks for the feedback.

Don't know if I can or not. But since Data Association is not related to this thread, I'd suggest starting a new one and be as explict as you can on your question.

What you have
What your required results should be
Version of Excel
etc, etc
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,285
Members
452,902
Latest member
Knuddeluff

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