Conditional formatting

GordonLS

Board Regular
Joined
May 28, 2021
Messages
89
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Good morning. I need the following to fill right to the last populated cell in Row 1.
The range is correct working off E2, but my issue is that the conditional formatting stops at the last full populated column. In this case it is column P. Columns O and beyond are not completely populated.

'fill rows with color based off alternating order numbers

Range("a2", Range("a2").End(xlDown).End(xlToRight)).Select
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=MOD(SUMPRODUCT(--($e$2:$e2<>$e$1:$e1)),2)"
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorDark1
.TintAndShade = -0.14996795556505
End With


1646583715573.png
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
See if this gives you what you want:
VBA Code:
Dim lastRow as Long
Dim lastCol as Long
Dim rng as Range

lastRow = Cells(Rows.Count, "A").End(xlUp).Row
lastCol = Cells(1, Columns.Count).End(xlToLeft).Column

Set rng = Range(Cells(2, 1), Cells(lastRow, lastCol))

rng.FormatConditions.Add Type:=xlExpression, Formula1:= _
    "=MOD(SUMPRODUCT(--($e$2:$e2<>$e$1:$e1)),2)"
rng.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With rng.FormatConditions(1).Interior
    .PatternColorIndex = xlAutomatic
    .ThemeColor = xlThemeColorDark1
    .TintAndShade = -0.14996795556505
End With
 
Upvote 0
Solution
Sorry for the delay Joe. Thanks for the solution.
 
Upvote 0
You are welcome.
 
Upvote 0
Good evening. I need Column C be populated based off the following:

The sum of Column A and B need to be to populated in the last row of column C for the total of each Order Number in Column D.

In other words Column C6 will be the total of A2:B6. C7-C9 needs to be blank, so I'm thinking (iferror then blank). C10 will equal the sum of A10:B10. C11 will be blank and C17 should be the sum of A12:B17, etc.

1647211023604.png
 
Upvote 0
Good evening. I need Column C be populated based off the following:

The sum of Column A and B need to be to populated in the last row of column C for the total of each Order Number in Column D.

In other words Column C6 will be the total of A2:B6. C7-C9 needs to be blank, so I'm thinking (iferror then blank). C10 will equal the sum of A10:B10. C11 will be blank and C17 should be the sum of A12:B17, etc.

View attachment 59959
That is really a new question from your original, and should therefore be posted to a new thread.
 
Upvote 0
Why did you mark your new question as the solution?
You should only mark the post that contains the solution to your original question as the solution.
I have changed it back.
 
Upvote 0

Forum statistics

Threads
1,215,029
Messages
6,122,755
Members
449,094
Latest member
dsharae57

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