Change Row height and colour based on value

Andyjk1984

New Member
Joined
May 17, 2019
Messages
11
Hi great people
I have a work stream spreadsheet that I sort by date, the only thing that I'm.struggling with is the height of the rows based of column A containing the number 1, and then colouring the row (A to M) being dark grey

Can anyone help me?
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
What height should the row be if it contains 1 in col A?
 
Upvote 0
Also is col A hard values, or formulae?
 
Upvote 0
In that case how about
Code:
Sub Andyjk1984()
   Dim Cl As Range
   
   For Each Cl In Range("A1", Range("A" & Rows.Count).End(xlUp))
      If Cl.Value = 1 Then
         Cl.RowHeight = 33
         Cl.Resize(, 13).Interior.ColorIndex = 16
      End If
   Next Cl
End Sub
 
Upvote 0
Glad to help & thanks for the feedback
 
Upvote 0
Sorry, 1 more thing you can, is there a way that I can reset the other rows that dont meet the criteria it resets the rows height back to what it was (20)
 
Upvote 0
How about
Code:
Sub Andyjk1984()
   Dim Cl As Range
   
   For Each Cl In Range("A1", Range("A" & Rows.Count).End(xlUp))
      If Cl.Value = 1 Then
         Cl.RowHeight = 33
         Cl.Resize(, 13).Interior.ColorIndex = 16
      Else
         Cl.RowHeight = 20
      End If
   Next Cl
End Sub
 
Upvote 0
Works a treat, now inhale a totally unexpected issue, so I have a macro that sorts it in date order which all the dates are in order expect the first 1, for example it goes 27/04/2020 to 22/04/2019, 06/05/2019,,,, proceeds in the desired order, I've checked the cells are all formatted the same, any ideas?
 
Upvote 0

Forum statistics

Threads
1,223,702
Messages
6,173,953
Members
452,539
Latest member
delvey

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