Countif Failing Due To Different Comparison Types (Dates)

Ark68

Well-known Member
Joined
Mar 23, 2004
Messages
4,564
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
I am having difficulty with this code

VBA Code:
Set wb_rmrsrc = Workbooks.Open(anpath & "rmr1.xlsx", True, True)
Set ws_rmrsource = wb_rmrsrc.Worksheets("Sheet1")
cnt_idate = Application.WorksheetFunction.CountIf(ws_rmrsource.Columns(1), inq_date)

inq_date = 44023 (serial of July 12, 2020)
wb_rmsrc is accessed in the background but not opened
column 1 of ws_rmrsource contains dates, but I think they may be text. When I try to change their cell format to number, nothing happens so I assume that they aren;t true dates.

I am getting a value of 0 for cnt_date when the datavase should find 8 equal date values.
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Code:
cnt_idate = Application.WorksheetFunction.CountIf(ws_rmrsource.Columns(1), CDate(inq_date))

Thank you!
 
Upvote 0

Forum statistics

Threads
1,214,920
Messages
6,122,276
Members
449,075
Latest member
staticfluids

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