If greater than today highlight cell issue
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
I'm trying to setup a simple solution to highlight cells that have a date that is greater than today's date. What I currently have is the following:
Sub Test()
Dim lrow As Long
lrow = Cells(Rows.Count, 1).End(xlUp).Row
Columns("H:H").EntireColumn.AutoFit
If Range("H2:H" & lrow).Value > Date Then Cell.Interior.Color = vbYellow
End Sub
I keep getting a "Type Mismatch" erroer but the column (H) is formatted as Date so I'm not sure what I'm doing wrong. Any help or direction would be greatly appreciated.
excel vba excel-vba
add a comment |
I'm trying to setup a simple solution to highlight cells that have a date that is greater than today's date. What I currently have is the following:
Sub Test()
Dim lrow As Long
lrow = Cells(Rows.Count, 1).End(xlUp).Row
Columns("H:H").EntireColumn.AutoFit
If Range("H2:H" & lrow).Value > Date Then Cell.Interior.Color = vbYellow
End Sub
I keep getting a "Type Mismatch" erroer but the column (H) is formatted as Date so I'm not sure what I'm doing wrong. Any help or direction would be greatly appreciated.
excel vba excel-vba
add a comment |
I'm trying to setup a simple solution to highlight cells that have a date that is greater than today's date. What I currently have is the following:
Sub Test()
Dim lrow As Long
lrow = Cells(Rows.Count, 1).End(xlUp).Row
Columns("H:H").EntireColumn.AutoFit
If Range("H2:H" & lrow).Value > Date Then Cell.Interior.Color = vbYellow
End Sub
I keep getting a "Type Mismatch" erroer but the column (H) is formatted as Date so I'm not sure what I'm doing wrong. Any help or direction would be greatly appreciated.
excel vba excel-vba
I'm trying to setup a simple solution to highlight cells that have a date that is greater than today's date. What I currently have is the following:
Sub Test()
Dim lrow As Long
lrow = Cells(Rows.Count, 1).End(xlUp).Row
Columns("H:H").EntireColumn.AutoFit
If Range("H2:H" & lrow).Value > Date Then Cell.Interior.Color = vbYellow
End Sub
I keep getting a "Type Mismatch" erroer but the column (H) is formatted as Date so I'm not sure what I'm doing wrong. Any help or direction would be greatly appreciated.
excel vba excel-vba
excel vba excel-vba
edited Nov 16 '18 at 19:19
Mathieu Guindon
45k770157
45k770157
asked Nov 16 '18 at 19:15
DekeDeke
1339
1339
add a comment |
add a comment |
4 Answers
4
active
oldest
votes
In response to @MatthieuGuindon's suggestion to @CharlesPL's answer, here's some code that does the conditional formatting. I've set it so it highlights dates that are after the day you run it as a bright yellow.
Option Explicit
Sub setCondFormat()
Dim lrow As Long
lrow = ActiveSheet.Range("H" & ActiveSheet.Rows.Count).End(xlUp).Row
With Range("H2:H" & lrow)
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=H2>TODAY()"
With .FormatConditions(.FormatConditions.Count)
.SetFirstPriority
With .Interior
.PatternColorIndex = xlAutomatic
.Color = 65535
.TintAndShade = 0
End With
End With
End With
End Sub
absolutely perfect solution! Thanks again everyone!!
– Deke
Nov 26 '18 at 18:47
add a comment |
Range("H2:H" & lrow).Value
will be a 2D array (the Value
of a Range
is always a 2D array if more than a single cell is involved); you're getting a type mismatch error because you can't compare a 2D array to a Date
; if you can't use a conditional formatting, you need to compare the individual array subscripts.
Last thing you want to do is to iterate each individual cells (otherwise your next question will be "how do I make this loop run faster?"). Get that array into a Variant
, and iterate that array - since it's only 1 column, make it a 1D array with Application.Transpose
:
Dim values As Variant
values = Application.Transpose(Range("H2:H" & lastRow).Value)
Dim i As Long, current As Long
For i = LBound(values) To UBound(values)
current = i + 1 'array would be 1-based, so to start at row 2 we need to offset by 1
If values(i) > Date Then
ActiveSheet.Cells(current, 8).Interior.Color = vbYellow
End If
Next
That way you only hit the worksheet when you have to.
This would also work well! Thanks all for your help!!!
– Deke
Nov 16 '18 at 19:41
2
@Deke please note that the answer you picked is the single slowest working solution. It doesn't scale, and will perform terribly given a large number of cells to iterate. Avoid hitting the worksheet as much as possible if you want performant code.
– Mathieu Guindon
Nov 16 '18 at 19:43
Hint to internationalization: in my local middle European setting I have to assign viaValue2
, i.e.Application.Transpose(Range("H2:H" & lastRow).Value2)
to get correctly highlighted cells :-)
– T.M.
Nov 16 '18 at 20:18
It seems that Central European date values of the local DMY type (as opposed to the MDY type) in thevalues
array automatically(?) change to VarTypevbString
when assigned using.Value
. - Solutions:.Value2
instead of assignment via.Value
; otherwise you'd have to change backvalues
item comparisons viaCDate()
in DMY type case). :-) @MathieuGuindon
– T.M.
Nov 17 '18 at 18:39
add a comment |
Use conditional formatting! As the name suggests, this is build for that!
Microsoft blog post on date conditional formating
normally this would work well I totally agree. But the spreadsheet is constantly updated and rebuilt which would require the rule to be added everyday and I'm trying to automate a process.
– Deke
Nov 16 '18 at 19:41
1
@Deke conditional formatting rules can be automated too.
– Mathieu Guindon
Nov 16 '18 at 19:44
1
And then there is the strength ofNamed Ranges
. Depending on how this is rebuilt, your formatting can be applied to a named range which reduces the maintenance over using explicit range addresses.
– AJD
Nov 16 '18 at 20:54
1
Personally, I prefer conditional formatting because of a smaller file size -Interior.Color
applied on single cells can produce considerable file sizes (as this information gets multiplied for each cell) :-;
– T.M.
Nov 16 '18 at 21:02
add a comment |
I would recommend iterating over the range of cells and testing each cell individually. Please see below.
Dim rng As Range, cell As Range
Set rng = Range("H:H")
For Each cell In rng
If cell.Value > Date Then cell.Interior.Color = vbYellow
Next cell
Works well thanks!!!!
– Deke
Nov 16 '18 at 19:35
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53344065%2fif-greater-than-today-highlight-cell-issue%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
In response to @MatthieuGuindon's suggestion to @CharlesPL's answer, here's some code that does the conditional formatting. I've set it so it highlights dates that are after the day you run it as a bright yellow.
Option Explicit
Sub setCondFormat()
Dim lrow As Long
lrow = ActiveSheet.Range("H" & ActiveSheet.Rows.Count).End(xlUp).Row
With Range("H2:H" & lrow)
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=H2>TODAY()"
With .FormatConditions(.FormatConditions.Count)
.SetFirstPriority
With .Interior
.PatternColorIndex = xlAutomatic
.Color = 65535
.TintAndShade = 0
End With
End With
End With
End Sub
absolutely perfect solution! Thanks again everyone!!
– Deke
Nov 26 '18 at 18:47
add a comment |
In response to @MatthieuGuindon's suggestion to @CharlesPL's answer, here's some code that does the conditional formatting. I've set it so it highlights dates that are after the day you run it as a bright yellow.
Option Explicit
Sub setCondFormat()
Dim lrow As Long
lrow = ActiveSheet.Range("H" & ActiveSheet.Rows.Count).End(xlUp).Row
With Range("H2:H" & lrow)
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=H2>TODAY()"
With .FormatConditions(.FormatConditions.Count)
.SetFirstPriority
With .Interior
.PatternColorIndex = xlAutomatic
.Color = 65535
.TintAndShade = 0
End With
End With
End With
End Sub
absolutely perfect solution! Thanks again everyone!!
– Deke
Nov 26 '18 at 18:47
add a comment |
In response to @MatthieuGuindon's suggestion to @CharlesPL's answer, here's some code that does the conditional formatting. I've set it so it highlights dates that are after the day you run it as a bright yellow.
Option Explicit
Sub setCondFormat()
Dim lrow As Long
lrow = ActiveSheet.Range("H" & ActiveSheet.Rows.Count).End(xlUp).Row
With Range("H2:H" & lrow)
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=H2>TODAY()"
With .FormatConditions(.FormatConditions.Count)
.SetFirstPriority
With .Interior
.PatternColorIndex = xlAutomatic
.Color = 65535
.TintAndShade = 0
End With
End With
End With
End Sub
In response to @MatthieuGuindon's suggestion to @CharlesPL's answer, here's some code that does the conditional formatting. I've set it so it highlights dates that are after the day you run it as a bright yellow.
Option Explicit
Sub setCondFormat()
Dim lrow As Long
lrow = ActiveSheet.Range("H" & ActiveSheet.Rows.Count).End(xlUp).Row
With Range("H2:H" & lrow)
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=H2>TODAY()"
With .FormatConditions(.FormatConditions.Count)
.SetFirstPriority
With .Interior
.PatternColorIndex = xlAutomatic
.Color = 65535
.TintAndShade = 0
End With
End With
End With
End Sub
answered Nov 16 '18 at 22:57
Jchang43Jchang43
800213
800213
absolutely perfect solution! Thanks again everyone!!
– Deke
Nov 26 '18 at 18:47
add a comment |
absolutely perfect solution! Thanks again everyone!!
– Deke
Nov 26 '18 at 18:47
absolutely perfect solution! Thanks again everyone!!
– Deke
Nov 26 '18 at 18:47
absolutely perfect solution! Thanks again everyone!!
– Deke
Nov 26 '18 at 18:47
add a comment |
Range("H2:H" & lrow).Value
will be a 2D array (the Value
of a Range
is always a 2D array if more than a single cell is involved); you're getting a type mismatch error because you can't compare a 2D array to a Date
; if you can't use a conditional formatting, you need to compare the individual array subscripts.
Last thing you want to do is to iterate each individual cells (otherwise your next question will be "how do I make this loop run faster?"). Get that array into a Variant
, and iterate that array - since it's only 1 column, make it a 1D array with Application.Transpose
:
Dim values As Variant
values = Application.Transpose(Range("H2:H" & lastRow).Value)
Dim i As Long, current As Long
For i = LBound(values) To UBound(values)
current = i + 1 'array would be 1-based, so to start at row 2 we need to offset by 1
If values(i) > Date Then
ActiveSheet.Cells(current, 8).Interior.Color = vbYellow
End If
Next
That way you only hit the worksheet when you have to.
This would also work well! Thanks all for your help!!!
– Deke
Nov 16 '18 at 19:41
2
@Deke please note that the answer you picked is the single slowest working solution. It doesn't scale, and will perform terribly given a large number of cells to iterate. Avoid hitting the worksheet as much as possible if you want performant code.
– Mathieu Guindon
Nov 16 '18 at 19:43
Hint to internationalization: in my local middle European setting I have to assign viaValue2
, i.e.Application.Transpose(Range("H2:H" & lastRow).Value2)
to get correctly highlighted cells :-)
– T.M.
Nov 16 '18 at 20:18
It seems that Central European date values of the local DMY type (as opposed to the MDY type) in thevalues
array automatically(?) change to VarTypevbString
when assigned using.Value
. - Solutions:.Value2
instead of assignment via.Value
; otherwise you'd have to change backvalues
item comparisons viaCDate()
in DMY type case). :-) @MathieuGuindon
– T.M.
Nov 17 '18 at 18:39
add a comment |
Range("H2:H" & lrow).Value
will be a 2D array (the Value
of a Range
is always a 2D array if more than a single cell is involved); you're getting a type mismatch error because you can't compare a 2D array to a Date
; if you can't use a conditional formatting, you need to compare the individual array subscripts.
Last thing you want to do is to iterate each individual cells (otherwise your next question will be "how do I make this loop run faster?"). Get that array into a Variant
, and iterate that array - since it's only 1 column, make it a 1D array with Application.Transpose
:
Dim values As Variant
values = Application.Transpose(Range("H2:H" & lastRow).Value)
Dim i As Long, current As Long
For i = LBound(values) To UBound(values)
current = i + 1 'array would be 1-based, so to start at row 2 we need to offset by 1
If values(i) > Date Then
ActiveSheet.Cells(current, 8).Interior.Color = vbYellow
End If
Next
That way you only hit the worksheet when you have to.
This would also work well! Thanks all for your help!!!
– Deke
Nov 16 '18 at 19:41
2
@Deke please note that the answer you picked is the single slowest working solution. It doesn't scale, and will perform terribly given a large number of cells to iterate. Avoid hitting the worksheet as much as possible if you want performant code.
– Mathieu Guindon
Nov 16 '18 at 19:43
Hint to internationalization: in my local middle European setting I have to assign viaValue2
, i.e.Application.Transpose(Range("H2:H" & lastRow).Value2)
to get correctly highlighted cells :-)
– T.M.
Nov 16 '18 at 20:18
It seems that Central European date values of the local DMY type (as opposed to the MDY type) in thevalues
array automatically(?) change to VarTypevbString
when assigned using.Value
. - Solutions:.Value2
instead of assignment via.Value
; otherwise you'd have to change backvalues
item comparisons viaCDate()
in DMY type case). :-) @MathieuGuindon
– T.M.
Nov 17 '18 at 18:39
add a comment |
Range("H2:H" & lrow).Value
will be a 2D array (the Value
of a Range
is always a 2D array if more than a single cell is involved); you're getting a type mismatch error because you can't compare a 2D array to a Date
; if you can't use a conditional formatting, you need to compare the individual array subscripts.
Last thing you want to do is to iterate each individual cells (otherwise your next question will be "how do I make this loop run faster?"). Get that array into a Variant
, and iterate that array - since it's only 1 column, make it a 1D array with Application.Transpose
:
Dim values As Variant
values = Application.Transpose(Range("H2:H" & lastRow).Value)
Dim i As Long, current As Long
For i = LBound(values) To UBound(values)
current = i + 1 'array would be 1-based, so to start at row 2 we need to offset by 1
If values(i) > Date Then
ActiveSheet.Cells(current, 8).Interior.Color = vbYellow
End If
Next
That way you only hit the worksheet when you have to.
Range("H2:H" & lrow).Value
will be a 2D array (the Value
of a Range
is always a 2D array if more than a single cell is involved); you're getting a type mismatch error because you can't compare a 2D array to a Date
; if you can't use a conditional formatting, you need to compare the individual array subscripts.
Last thing you want to do is to iterate each individual cells (otherwise your next question will be "how do I make this loop run faster?"). Get that array into a Variant
, and iterate that array - since it's only 1 column, make it a 1D array with Application.Transpose
:
Dim values As Variant
values = Application.Transpose(Range("H2:H" & lastRow).Value)
Dim i As Long, current As Long
For i = LBound(values) To UBound(values)
current = i + 1 'array would be 1-based, so to start at row 2 we need to offset by 1
If values(i) > Date Then
ActiveSheet.Cells(current, 8).Interior.Color = vbYellow
End If
Next
That way you only hit the worksheet when you have to.
answered Nov 16 '18 at 19:31
Mathieu GuindonMathieu Guindon
45k770157
45k770157
This would also work well! Thanks all for your help!!!
– Deke
Nov 16 '18 at 19:41
2
@Deke please note that the answer you picked is the single slowest working solution. It doesn't scale, and will perform terribly given a large number of cells to iterate. Avoid hitting the worksheet as much as possible if you want performant code.
– Mathieu Guindon
Nov 16 '18 at 19:43
Hint to internationalization: in my local middle European setting I have to assign viaValue2
, i.e.Application.Transpose(Range("H2:H" & lastRow).Value2)
to get correctly highlighted cells :-)
– T.M.
Nov 16 '18 at 20:18
It seems that Central European date values of the local DMY type (as opposed to the MDY type) in thevalues
array automatically(?) change to VarTypevbString
when assigned using.Value
. - Solutions:.Value2
instead of assignment via.Value
; otherwise you'd have to change backvalues
item comparisons viaCDate()
in DMY type case). :-) @MathieuGuindon
– T.M.
Nov 17 '18 at 18:39
add a comment |
This would also work well! Thanks all for your help!!!
– Deke
Nov 16 '18 at 19:41
2
@Deke please note that the answer you picked is the single slowest working solution. It doesn't scale, and will perform terribly given a large number of cells to iterate. Avoid hitting the worksheet as much as possible if you want performant code.
– Mathieu Guindon
Nov 16 '18 at 19:43
Hint to internationalization: in my local middle European setting I have to assign viaValue2
, i.e.Application.Transpose(Range("H2:H" & lastRow).Value2)
to get correctly highlighted cells :-)
– T.M.
Nov 16 '18 at 20:18
It seems that Central European date values of the local DMY type (as opposed to the MDY type) in thevalues
array automatically(?) change to VarTypevbString
when assigned using.Value
. - Solutions:.Value2
instead of assignment via.Value
; otherwise you'd have to change backvalues
item comparisons viaCDate()
in DMY type case). :-) @MathieuGuindon
– T.M.
Nov 17 '18 at 18:39
This would also work well! Thanks all for your help!!!
– Deke
Nov 16 '18 at 19:41
This would also work well! Thanks all for your help!!!
– Deke
Nov 16 '18 at 19:41
2
2
@Deke please note that the answer you picked is the single slowest working solution. It doesn't scale, and will perform terribly given a large number of cells to iterate. Avoid hitting the worksheet as much as possible if you want performant code.
– Mathieu Guindon
Nov 16 '18 at 19:43
@Deke please note that the answer you picked is the single slowest working solution. It doesn't scale, and will perform terribly given a large number of cells to iterate. Avoid hitting the worksheet as much as possible if you want performant code.
– Mathieu Guindon
Nov 16 '18 at 19:43
Hint to internationalization: in my local middle European setting I have to assign via
Value2
, i.e. Application.Transpose(Range("H2:H" & lastRow).Value2)
to get correctly highlighted cells :-)– T.M.
Nov 16 '18 at 20:18
Hint to internationalization: in my local middle European setting I have to assign via
Value2
, i.e. Application.Transpose(Range("H2:H" & lastRow).Value2)
to get correctly highlighted cells :-)– T.M.
Nov 16 '18 at 20:18
It seems that Central European date values of the local DMY type (as opposed to the MDY type) in the
values
array automatically(?) change to VarType vbString
when assigned using .Value
. - Solutions: .Value2
instead of assignment via .Value
; otherwise you'd have to change back values
item comparisons via CDate()
in DMY type case). :-) @MathieuGuindon– T.M.
Nov 17 '18 at 18:39
It seems that Central European date values of the local DMY type (as opposed to the MDY type) in the
values
array automatically(?) change to VarType vbString
when assigned using .Value
. - Solutions: .Value2
instead of assignment via .Value
; otherwise you'd have to change back values
item comparisons via CDate()
in DMY type case). :-) @MathieuGuindon– T.M.
Nov 17 '18 at 18:39
add a comment |
Use conditional formatting! As the name suggests, this is build for that!
Microsoft blog post on date conditional formating
normally this would work well I totally agree. But the spreadsheet is constantly updated and rebuilt which would require the rule to be added everyday and I'm trying to automate a process.
– Deke
Nov 16 '18 at 19:41
1
@Deke conditional formatting rules can be automated too.
– Mathieu Guindon
Nov 16 '18 at 19:44
1
And then there is the strength ofNamed Ranges
. Depending on how this is rebuilt, your formatting can be applied to a named range which reduces the maintenance over using explicit range addresses.
– AJD
Nov 16 '18 at 20:54
1
Personally, I prefer conditional formatting because of a smaller file size -Interior.Color
applied on single cells can produce considerable file sizes (as this information gets multiplied for each cell) :-;
– T.M.
Nov 16 '18 at 21:02
add a comment |
Use conditional formatting! As the name suggests, this is build for that!
Microsoft blog post on date conditional formating
normally this would work well I totally agree. But the spreadsheet is constantly updated and rebuilt which would require the rule to be added everyday and I'm trying to automate a process.
– Deke
Nov 16 '18 at 19:41
1
@Deke conditional formatting rules can be automated too.
– Mathieu Guindon
Nov 16 '18 at 19:44
1
And then there is the strength ofNamed Ranges
. Depending on how this is rebuilt, your formatting can be applied to a named range which reduces the maintenance over using explicit range addresses.
– AJD
Nov 16 '18 at 20:54
1
Personally, I prefer conditional formatting because of a smaller file size -Interior.Color
applied on single cells can produce considerable file sizes (as this information gets multiplied for each cell) :-;
– T.M.
Nov 16 '18 at 21:02
add a comment |
Use conditional formatting! As the name suggests, this is build for that!
Microsoft blog post on date conditional formating
Use conditional formatting! As the name suggests, this is build for that!
Microsoft blog post on date conditional formating
answered Nov 16 '18 at 19:28
CharlesPLCharlesPL
1578
1578
normally this would work well I totally agree. But the spreadsheet is constantly updated and rebuilt which would require the rule to be added everyday and I'm trying to automate a process.
– Deke
Nov 16 '18 at 19:41
1
@Deke conditional formatting rules can be automated too.
– Mathieu Guindon
Nov 16 '18 at 19:44
1
And then there is the strength ofNamed Ranges
. Depending on how this is rebuilt, your formatting can be applied to a named range which reduces the maintenance over using explicit range addresses.
– AJD
Nov 16 '18 at 20:54
1
Personally, I prefer conditional formatting because of a smaller file size -Interior.Color
applied on single cells can produce considerable file sizes (as this information gets multiplied for each cell) :-;
– T.M.
Nov 16 '18 at 21:02
add a comment |
normally this would work well I totally agree. But the spreadsheet is constantly updated and rebuilt which would require the rule to be added everyday and I'm trying to automate a process.
– Deke
Nov 16 '18 at 19:41
1
@Deke conditional formatting rules can be automated too.
– Mathieu Guindon
Nov 16 '18 at 19:44
1
And then there is the strength ofNamed Ranges
. Depending on how this is rebuilt, your formatting can be applied to a named range which reduces the maintenance over using explicit range addresses.
– AJD
Nov 16 '18 at 20:54
1
Personally, I prefer conditional formatting because of a smaller file size -Interior.Color
applied on single cells can produce considerable file sizes (as this information gets multiplied for each cell) :-;
– T.M.
Nov 16 '18 at 21:02
normally this would work well I totally agree. But the spreadsheet is constantly updated and rebuilt which would require the rule to be added everyday and I'm trying to automate a process.
– Deke
Nov 16 '18 at 19:41
normally this would work well I totally agree. But the spreadsheet is constantly updated and rebuilt which would require the rule to be added everyday and I'm trying to automate a process.
– Deke
Nov 16 '18 at 19:41
1
1
@Deke conditional formatting rules can be automated too.
– Mathieu Guindon
Nov 16 '18 at 19:44
@Deke conditional formatting rules can be automated too.
– Mathieu Guindon
Nov 16 '18 at 19:44
1
1
And then there is the strength of
Named Ranges
. Depending on how this is rebuilt, your formatting can be applied to a named range which reduces the maintenance over using explicit range addresses.– AJD
Nov 16 '18 at 20:54
And then there is the strength of
Named Ranges
. Depending on how this is rebuilt, your formatting can be applied to a named range which reduces the maintenance over using explicit range addresses.– AJD
Nov 16 '18 at 20:54
1
1
Personally, I prefer conditional formatting because of a smaller file size -
Interior.Color
applied on single cells can produce considerable file sizes (as this information gets multiplied for each cell) :-;– T.M.
Nov 16 '18 at 21:02
Personally, I prefer conditional formatting because of a smaller file size -
Interior.Color
applied on single cells can produce considerable file sizes (as this information gets multiplied for each cell) :-;– T.M.
Nov 16 '18 at 21:02
add a comment |
I would recommend iterating over the range of cells and testing each cell individually. Please see below.
Dim rng As Range, cell As Range
Set rng = Range("H:H")
For Each cell In rng
If cell.Value > Date Then cell.Interior.Color = vbYellow
Next cell
Works well thanks!!!!
– Deke
Nov 16 '18 at 19:35
add a comment |
I would recommend iterating over the range of cells and testing each cell individually. Please see below.
Dim rng As Range, cell As Range
Set rng = Range("H:H")
For Each cell In rng
If cell.Value > Date Then cell.Interior.Color = vbYellow
Next cell
Works well thanks!!!!
– Deke
Nov 16 '18 at 19:35
add a comment |
I would recommend iterating over the range of cells and testing each cell individually. Please see below.
Dim rng As Range, cell As Range
Set rng = Range("H:H")
For Each cell In rng
If cell.Value > Date Then cell.Interior.Color = vbYellow
Next cell
I would recommend iterating over the range of cells and testing each cell individually. Please see below.
Dim rng As Range, cell As Range
Set rng = Range("H:H")
For Each cell In rng
If cell.Value > Date Then cell.Interior.Color = vbYellow
Next cell
answered Nov 16 '18 at 19:26
DmegaffiDmegaffi
346
346
Works well thanks!!!!
– Deke
Nov 16 '18 at 19:35
add a comment |
Works well thanks!!!!
– Deke
Nov 16 '18 at 19:35
Works well thanks!!!!
– Deke
Nov 16 '18 at 19:35
Works well thanks!!!!
– Deke
Nov 16 '18 at 19:35
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53344065%2fif-greater-than-today-highlight-cell-issue%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown