Row Height adjusted based on content via code or Macro

SBass

New Member
Joined
Oct 11, 2017
Messages
17
I have a worksheet that contains two cells that are populated via a series of nested IF statements based on the contents of another cell. The issue is that one of the statements generates a MUCH longer text string than the other two options. To make the text appear aesthetically pleasing, the rows need to be at a height of 40 for the longer string, but only 15 for the other strings. I realize that I can't accomplish this with conditional formatting, but there has to be a way to do it. I'm open to ideas/suggestions, even if it includes simple code or a macro.
 
I thought that is what you wanted according to what you said in Post #5 :
Cell A73 populates based on the content of B8.
 
Upvote 0

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
Delete this row:
Code:
Range("A73") = Target
 
Upvote 0
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("B8")) Is Nothing Then Exit Sub
If Len(Target) > 9 Then
Range("A73").WrapText = True
End If
End Sub

Here is the Nested IF
=IF(B8="Business Management"," MBA-5121",IF(B8="Business Leadership", "MSOL-5104",IF(B8="Technology and Innovation Management","TIM-6120, TIM-6310, TIM-6510, TIM-6210, OR TIM-6410","")))
 
Upvote 0
Remove the nested if formula you currently have in A73 and try this macro in the worksheet code module:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Intersect(Target, Range("B8")) Is Nothing Then Exit Sub
    Select Case Target.Value
        Case "Business Management"
            Range("A73") = "MBA-5121"
        Case "Business Leadership"
            Range("A73") = "MSOL-5104"
        Case "Technology and Innovation Management"
            Range("A73") = "TIM-6120, TIM-6310, TIM-6510, TIM-6210, OR TIM-6410"
            Range("A73").WrapText = True
    End Select
End Sub
 
Upvote 0
Thank you for taking the time to help with this.

The latest code does the same thing as the Nested IF. It still doesn't adjust the row height.
 
Upvote 0

Excel 2012
AB
8
73 
74 
BBA
Cell Formulas
RangeFormula
A73=IF(B8="Business Management"," MBA-5110",IF(B8="Business Leadership", "MSOL-5103",IF(B8="Technology and Innovation Management","TIM-6101, TIM-6110, TIM-6301, TIM-6501, TIM-6601, OR TIM-5010","")))
A74=IF(B8="Business Management"," MBA-5121",IF(B8="Business Leadership", "MSOL-5104",IF(B8="Technology and Innovation Management","TIM-6120, TIM-6310, TIM-6510, TIM-6210, OR TIM-6410","")))
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,915
Members
452,366
Latest member
TePunaBloke

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