I have 6 different Excel tables in a single worksheet with similar column names and I would like to implement 1 formula in one of the columns in all these tables. I would like to populate the Sequence numbers (in the "Sequence" Columns) based on the Property Number repetitions in the "Property Number" Columns.
Following is the formula that I would like to replicate in the Excel tables:
General Formula: =IF(AND(E2=E2),COUNTIFS($E$2:E2,E2),"")
The same formula if I need to replicate it in Tables/Listobjects, looks like this:
=IF(AND([@PropertyNumber]=[@PropertyNumber]), COUNTIFS([@PropertyNumber]:[@PropertyNumber],[@PropertyNumber]),"")
I'm unable to use the Absolute References, but however, I would like to replicate the same Formula in VBA Code to populate the results as shown below:
I have tried to replicate the formula in VBA with the following code and it is throwing error that "property or method not supported"
Populating the formulas for Sequence Columns in all the RealProperty Tables
Dim RealPropertySequenceCol As Integer
Dim RealPropertyPropertyNumRow1 As Integer
Dim RealPropertyPropertyNumRows As Integer
Dim RealPropertyPropertyCol As Integer
Dim ListObjectTables As ListObject
Dim TblCounts As Integer
For Each ListObjectTables In RealPropertySht.ListObjects
RealPropertyPropertyNumRows = 1
If ListObjectTables = "RealPropertyRentalPropertyTaxableMajorMaintenanceOrRepairExpensesSubTable" Then
RealPropertyPropertyNumRow1 = ListObjectTables.ListColumns("PropertyNumber").DataBodyRange.Rows(1)
TblCounts = ListObjectTables.DataBodyRange.Rows.Count
If ListObjectTables.ListColumns("PropertyNumber").DataBodyRange.Rows(1).Value = ListObjectTables.ListColumns("PropertyNumber").DataBodyRange.Rows(1).Value Then
ListObjectTables.ListColumns("Sequence").DataBodyRange.Rows(1).Value = Application.WorksheetFunction.CountIfs(ListObjectTables.ListRows(TblCounts) - (ListObjectTables.ListRows(TblCounts) - ListObjectTables.ListRows(RealPropertyPropertyNumRow1)), RealPropertyPropertyNumRow1, "")
End If
End If
Next ListObjectTables
Please help me populate the sequence numbers based on the Property Numbers available in each table dynamically. Appreciate your help in advance.