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

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
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,213,546
Messages
6,114,256
Members
448,558
Latest member
aivin

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