Specific VBA Function

EAlexWolfe

New Member
Joined
Aug 6, 2024
Messages
3
Office Version
  1. 365
Platform
  1. Windows
I need a VBA macro that works on all worksheets in the active workbook. The macro should start by applying a filter to the range A4. Then, it should sort the rows starting from row 5 to the last populated row, based on the values in column U, in descending order. After sorting, I want the macro to format the values in columns J and K (from row 5 downwards) as numbers without decimals and with comma separators.

Next, the macro should highlight specific cells in light red. It should highlight cells in column K if the value in cell H2 is C (indicating a Markup) and the volume in K does not meet certain criteria based on the value in N2. Similarly, it should highlight cells in column J if the value in F2 is C (indicating a Markdown) and the volume in J does not meet certain criteria based on the value in M2. Additionally, any cells in column D from row 5 downwards that match the value in G2 should also be highlighted in light red, as well as any cells in column V from row 5 downwards that contain a value less than 50. After applying the red highlights, the macro should check for the first row with no red highlights. If the value in column U of that row is greater than or equal to the value in Q2, the entire row should be highlighted in light green. If no row meets the green highlighting criteria, the macro should look for a row where the value in column U is within 0.05% of the value in Q2, and if found, highlight that row in a light dusty blue (RGB: 176, 196, 222). If neither of these conditions is met, the topmost row that had no red highlights should be highlighted in a slightly darker shade of red (RGB: 255, 160, 160).

Finally, the macro should display a message box indicating that the highlighting is completed for all sheets.
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).

Forum statistics

Threads
1,223,705
Messages
6,173,996
Members
452,542
Latest member
Bricklin

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