Set row height based on the first 14 characters in a string

Brian F

Active Member
Joined
Aug 31, 2009
Messages
256
Excel 2010; I am setting row heights on the basis of some parameters. I have the following statement;

If targetCell.Value = "Photo Comment: " Then
targetCell.RowHeight = 185

But what I really want is to recognize only the phrase;

"Photo Comment:" in a text string that might be much longer e.g,

"Photo Comment: The photo above depicts yata, yata.........."

So, I want to recognize the first 14 character as "Photo Comment:" and then have the row height adjust to 185. So it involves "Left" and "Len" (I'm thinkin') but the syntax is beyond me.

Any help would be greatly appreciated.
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
You didn't indicate the type of event you want to use so I'll assume it to be a worksheet change event which goes into a module for the sheet of interest:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If InStr(1, Target.Value, "Photo Comment") > 0 Then
    Target.RowHeight = 185
End If
End Sub
 
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