Change column width based on cell value

Jerald

New Member
Joined
Jun 6, 2006
Messages
3
Hi,
I have below macro to "change row height based on cell value"
I need a similar macro to "change column width based on cell value"
my knowledge in VBA is zero.
Thanks for your help



Sub rowheight()
'Updateby Extendoffice
Dim hgt As Variant
Dim WorkRng As Range
xTxt = ActiveWindow.RangeSelection.Address
Set WorkRng = Application.InputBox("please select the data range:", "Kutools for Excel", xTxt, , , , , 8)
For Each H In WorkRng
If H.Value > 15 Then
hgt = H.Value
H.EntireRow.Select
Selection.rowheight = hgt
End If
Next H
End Sub
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Cross-posting (posting the same question in more than one forum) is not against our rules, but the method of doing so is covered by #13 of the Forum Rules.

Be sure to follow & read the link at the end of the rule too!

Cross posted at: Change column width based on cell value
If you have posted the question at more places, please provide links to those as well.

If you do cross-post in the future and also provide links, then there shouldn’t be a problem.
 
Upvote 0
Hi,
I have below macro to "change row height based on cell value"
I need a similar macro to "change column width based on cell value"
my knowledge in VBA is zero.
Thanks for your help



Sub rowheight()
'Updateby Extendoffice
Dim hgt As Variant
Dim WorkRng As Range
xTxt = ActiveWindow.RangeSelection.Address
Set WorkRng = Application.InputBox("please select the data range:", "Kutools for Excel", xTxt, , , , , 8)
For Each H In WorkRng
If H.Value > 15 Then
hgt = H.Value
H.EntireRow.Select
Selection.rowheight = hgt
End If
Next H
End Sub
I have cross-posted at - https://www.excelforum.com/excel-pr...-change-column-width-based-on-cell-value.html
 
Upvote 0

Forum statistics

Threads
1,215,053
Messages
6,122,888
Members
449,097
Latest member
dbomb1414

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