Row Heights based on cell value multiple cells rolled into onw macro.

Livin404

Active Member
Joined
Jan 7, 2019
Messages
393
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Greetings. I have a macro that I need the height adjusted based on a small portion of text found in a cell. The cells had to be merged due to text I have within the cell, so I cannot use autofill. I can come up the a macro if the cells will never shift up or down, but that is not an option.. The range will start on A1 and will go down the rows until the end of the document. For example it would search for a cell Value = ("*CAT I*") then the height would be adjusted to 67.5 only for that cells containing that cell value. I have 6 more similar to this one, so I'm hoping just for one macro rather than multiple ones. The second cell would search for a cell Value = ("*CAT II*") and will have a height adjusted to 58,5. This process hopefully can repeat itself for the other five cells.

Thank you.
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number

My Aswer Is This

Well-known Member
Joined
Jul 5, 2014
Messages
17,570
Office Version
  1. 2013
Platform
  1. Windows
You said:
then the height would be adjusted to 67.5 only for that cells containing that cell value.

Rows and columns can only be sized for the entire row or column.
You cannot have just a potion of the row or column with a particular height or width.
 

Livin404

Active Member
Joined
Jan 7, 2019
Messages
393
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
You said:
then the height would be adjusted to 67.5 only for that cells containing that cell value.

Rows and columns can only be sized for the entire row or column.
You cannot have just a potion of the row or column with a particular height or width.
Yes I know it’s one merged row which runs from Column A to I. I tested it on one which I knew where the row fell, so it was easy to do. I know it can be done. When I said cells I meant the “merged” cells.
 

Livin404

Active Member
Joined
Jan 7, 2019
Messages
393
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Sorry in advance, I posted this question last night, without being totally alert and I tried to delete it but 10 minutes and expired, so I could not remove it. Hopefully, this will provide better clarity.


Greetings. I have a macro that I need the height adjusted based on a text found in a cell. The cells had to be merged , so I cannot use autofill. The range will start on A1 and will go down the rows until the end of the document. I provided an image for better context. In the example it would search for a cell Value = ("*CAT I*") then the height would be adjusted to 67.5 only for merged cells containing that value. In another cell it would search for a cell Value = ("*CAT II*") and will have a height adjusted to 58,5. The last example would be = ("*Adjust the expiration date*") with a cell height of 46.5 This process hopefully can repeat itself for the other four cells. I'm hoping just for one macro rather than have seven different macros. I had to manually drag open the cells you see, which of course is not very efficient.

In the image you see, the darkened cells is purely to block names and details out. These depending how many errors are found in the advanced filter will vary, so the cells that I need to adjust the height won't always be the same, thus I think looking for keys words will be best.


Thank you.


Capture.JPG
 

Livin404

Active Member
Joined
Jan 7, 2019
Messages
393
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Good news the macro is finally sorted out. and it works great! Thanks to everyone for your help.


VBA Code:
Sub CAT_fishing()

Dim myRng As Range
Dim CAT1 As Range
Dim CAT2 As Range
Dim CAT3 As Range
Dim CAT4 As Range
Dim CAT5 As Range
Dim CAT6 As Range
Dim expDate As Range

Set myRng = ActiveSheet.Range("A1:I100")

Set CAT1 = myRng.Find(What:="*CAT I*", MatchCase:=True)
Set CAT2 = myRng.Find(What:="*CAT II*", MatchCase:=True)
Set CAT3 = myRng.Find(What:="*CAT III*", MatchCase:=True)
Set CAT4 = myRng.Find(What:="*CAT IV*", MatchCase:=True)
Set CAT5 = myRng.Find(What:="*CAT V*", MatchCase:=True)
Set CAT6 = myRng.Find(What:="*CAT VI*", MatchCase:=True)
Set expDate = myRng.Find(What:="*Adjust the expiration date*", MatchCase:=True)

If CAT1 Is Nothing Then Exit Sub
If CAT2 Is Nothing Then Exit Sub
If CAT3 Is Nothing Then Exit Sub
If CAT4 Is Nothing Then Exit Sub
If CAT5 Is Nothing Then Exit Sub
If CAT6 Is Nothing Then Exit Sub
If expDate Is Nothing Then Exit Sub

CAT1.EntireRow.RowHeight = 67.5
CAT2.RowHeight = 58.5
CAT3.RowHeight = 42
CAT4.RowHeight = 87
CAT5.RowHeight = 85.2
CAT6.RowHeight = 116.4
expDate.RowHeight = 46.5

End Sub
 
Solution

Watch MrExcel Video

Forum statistics

Threads
1,129,717
Messages
5,637,947
Members
416,994
Latest member
cappiccolo

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
Top