tonywatsonhelp
Well-known Member
- Joined
- Feb 24, 2014
- Messages
- 3,210
- Office Version
- 365
- 2019
- 2016
- Platform
- Windows
Hi Everyone,
i have this macro that works great on the selected range
but i need it to work on other ranges, can i make this macro cover all the following ranges?
C120:G220?
i have this macro that works great on the selected range
but i need it to work on other ranges, can i make this macro cover all the following ranges?
C120:G220?
VBA Code:
Sub test1()
'On Error Resume Next
If Range("C120").Value = 0 Then
Range("A120").RowHeight = 15
Else
'Resize row code
With Range("C120:G120")
If .MergeCells And .WrapText Then
Set c = Range("C120").Cells(1, 1)
cWdth = c.ColumnWidth
Set ma = c.MergeArea
For Each cc In ma.Cells
MrgeWdth = MrgeWdth + cc.ColumnWidth + 1
Next
ma.MergeCells = False
c.ColumnWidth = MrgeWdth
c.EntireRow.AutoFit
NewRwHt = c.RowHeight
If NewRwHt < 15 Then
NewRwHt = 15
End If
c.ColumnWidth = cWdth
ma.MergeCells = True
ma.RowHeight = NewRwHt
cWdth = 0: MrgeWdth = 0
End If
End With
End If
End Sub