Ark68
Well-known Member
- Joined
- Mar 23, 2004
- Messages
- 4,616
- Office Version
- 365
- 2016
- Platform
- Windows
This is a snippit of my module code:
Stepping through the code with pbypass = False,
n_date = 2020-05-23
cnt_date = 24
cnt_rows = 6505 (calculated prior to this snippit)
rte = 6482
Worksheet ws_cd1 is the data source, column 1 holds dates.
The autofilter has has filtered out all instances on 2020-05-23, the visible rows are the other dates.
The problem is with the line in red ... a line of code which I was hoping would given me a count of the number of visible cells. With the 24 rows of data filtered out for 2020-05-23, there should be 6482 visible rows (RTE). I would anticipate that the value of TEST would give me that same value ... the number of rows visible in the data worksheets ws_cd1.
But it's not. It's giving me a value of 44060.9782474545.
Is anyone able to provide a solution to this problem?
Rich (BB code):
With ws_cd1
If pbypass = True Then
cnt_date = Application.WorksheetFunction.CountIf(.Columns(2), n_date)
Else
cnt_date = Application.WorksheetFunction.CountIf(.Columns(1), n_date)
End If
cnt_rows = Application.WorksheetFunction.Count(.Columns(1))
rte = cnt_rows - cnt_date
'unprotect core data
.Unprotect
With ws_gui1.Range("AP3") 'coredata unlock, fee data is already unlocked
.Value = "CORE DATA " & Chr(208) 'unlocked
.Font.Name = "Arial Narrow"
.Characters(Len(.Value), 1).Font.Name = "Webdings"
End With
'filter core data of all dates not equal to queried date
If pbypass <> True Then
If .AutoFilterMode Then .AutoFilterMode = False
.Range("A1").AutoFilter Field:=1, Criteria1:="<>" & n_date
test = Application.WorksheetFunction.Subtotal(1, .Columns(1))
'check for data error (count number of filtered rows to difference of queried date from total rows - should be equal)
If test <> rte Then
MsgBox "Data inconsitency encountered: Core_Data Date Redundancy"
Stop
End If
Stepping through the code with pbypass = False,
n_date = 2020-05-23
cnt_date = 24
cnt_rows = 6505 (calculated prior to this snippit)
rte = 6482
Worksheet ws_cd1 is the data source, column 1 holds dates.
The autofilter has has filtered out all instances on 2020-05-23, the visible rows are the other dates.
The problem is with the line in red ... a line of code which I was hoping would given me a count of the number of visible cells. With the 24 rows of data filtered out for 2020-05-23, there should be 6482 visible rows (RTE). I would anticipate that the value of TEST would give me that same value ... the number of rows visible in the data worksheets ws_cd1.
But it's not. It's giving me a value of 44060.9782474545.
Is anyone able to provide a solution to this problem?