If statement stopped working from one cell to the next, with formatting all the same

Guzzlr

Well-known Member
Joined
Apr 20, 2009
Messages
982
Office Version
  1. 2021
Platform
  1. Windows
Hello, I have a simple if statement that works down to row 51, bur for some reason, it just stops working, and all formatting and formulas remain the same.
Notice in P51 has the exact same formula as P6:P50 and it is working. However, in P51, and further down, it stops working.
I dont know why. Any comments on this oddity?
Thank you

3-21-2024_PM-Scheduling Spike Template_Orig.xlsm
DEFGHIJKLMNOP
150
250
34/1/20244/1/24
4 
5Planned Start DateAsset NameFacility NumberResponsible Org (Shop)Resource Assignment StatusWork Task DescriptionAsset IDAsset DescriptionEst PM DurationTotal Planned Working HoursTotal Planned Working Hours Corrected 
604/01/240.600.6
704/01/240.870.9
804/01/241.121.1
904/01/240.540.5
1004/01/240.540.5
1104/01/240.540.5
1204/01/240.540.5
1304/01/241.201.2
1404/01/241.201.2
1504/01/241.201.2
1604/01/241.201.2
1704/01/241.201.2
1804/01/240.971.0
1904/01/241.311.3
2004/01/241.311.3
2104/01/241.311.3
2204/01/241.311.3
2304/01/240.860.9
2404/01/240.860.9
2504/01/240.860.9
2604/01/240.860.9
2704/01/241.501.5
2804/01/241.501.5
2904/01/241.201.2
3004/01/241.711.7
3104/01/241.711.7
3204/01/241.021.0
3304/01/241.041.0
3404/01/244.934.9
3504/01/241.501.5
3604/01/242.922.9
3704/01/240.640.6
3804/01/240.640.6
3904/01/241.501.5
4004/01/240.630.6
4104/01/240.630.6
4204/01/240.540.5
4304/01/240.600.6
4404/01/240.600.6
4504/01/241.001.0
4604/01/240.540.5
4704/01/241.001.0
4804/01/240.590.6
4904/01/241.281.3
5004/01/240.300.3
514/1/20241.02 
5204/01/241.20 
5304/01/241.20 
5404/01/241.20 
5504/01/240.60 
5604/01/240.60 
5704/01/241.20 
Data
Cell Formulas
RangeFormula
O3O3=D6
P1P1=SUM(P4:P2500)
P2P2=SUBTOTAL(9,P4:P2500)
P3P3=O3
P4:P5P4=IF(AND(P$3>=$B4,P$3<=$C4),$L4,"")
P6:P49P6=IF(P$3=D6,N6,"4")
P50:P57P50=IF(P$3=D50,N50,"")
Cells with Conditional Formatting
CellConditionCell FormatStop If True
N1:HAG1Expression=N$1>=250textNO
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
No mystery. Your dates aren't integer, they're actually date plus time.

There is a small difference between:
P3 = 45383.29
D51 = 45383.31
 
Upvote 0
oh...you are correct: This is how the format for Start Date is coming from the report I run: 04/01/2024 07:00:00

Below is the VBA I use to get rid of the time stamp to only show date:
VBA Code:
Columns("D:D").NumberFormat = "m/d/yyyy"

Do you have the time to suggest code I should use, to leave only the date in m/d/yyyy format, with out the time stamp?
Thank you for your help
 
Upvote 0
Below is the VBA I use to get rid of the time stamp to only show date:
That will only affect the formatting/view, not the underlying value!

In an Excel formula, you can use the INT or TRUNC functions to remove the decimals off of numbers.
In VBA, if you using Variables, just declare your variables to be of the INTEGER or LONG types.
 
Upvote 0
In VBA, if you using Variables, just declare your variables to be of the INTEGER or LONG types.
So I tried this, but it faults on me. So it's obviously not what you mean...sorry.

VBA Code:
Dim d As Long
d = Columns("D:D").NumberFormat = "mm/dd/yy"
 
Upvote 0
To convert using VBA, you could do something like this:

VBA Code:
With Range("D6:D" & Range("D" & Rows.Count).End(xlUp).Row)
    .Value = Evaluate("=IF(" & .Address & "="""","""",INT(" & .Address & "))")
End With

There are other options, as @Joe4 says.

For example, you could simply change:

O3 to = INT(D6), and
P6 to =IF(P$3=INT(D6),N6,"4") (It's not clear why you're using text "4" rather than numeric 4, and why this changes to "" further down the column?)

Or you could use a helper column to calculate integer values, e.g. Q6=INT(D6) copied down, and then copy/paste values back over column D.
 
Upvote 0
Solution
So I tried this, but it faults on me. So it's obviously not what you mean...sorry.

VBA Code:
Dim d As Long
d = Columns("D:D").NumberFormat = "mm/dd/yy"
You are mixing up two very different things!
Changing the formatting of a column is very different than truncating the decimals values off of numbers.
(And you cannot set a WHOLE column equal to a single numeric variable!)

Steven shows you the details of various different ways you can do it.
Of course, if you are trying to incorporate this into some pre-existing VBA code that you have, it would be most helpful to post that code.
 
Upvote 0
To convert using VBA, you could do something like this:

VBA Code:
With Range("D6:D" & Range("D" & Rows.Count).End(xlUp).Row)
    .Value = Evaluate("=IF(" & .Address & "="""","""",INT(" & .Address & "))")
End With

There are other options, as @Joe4 says.

For example, you could simply change:

O3 to = INT(D6), and
P6 to =IF(P$3=INT(D6),N6,"4") (It's not clear why you're using text "4" rather than numeric 4, and why this changes to "" further down the column?)

Or you could use a helper column to calculate integer values, e.g. Q6=INT(D6) copied down, and then copy/paste values back over column D.

This is working nicely. Thank you very much for the help...
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,184
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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