Hello all... it's been a while since I've been on here.
I have a formula in a column that checks to see if a value in another column is unique. It puts 1 if it's the first time it's seen it, and 0 if it isn't unique. Here is the formula:
That same logic is also used in other formulas to do some special math to make sure that I only count things once. Normally I could accomplish this with my pivots, but due to the nature of what we are doing, the data model method doesn't work. We also use grouping, and I can't for the life of me understand why you can't do a data model AND grouping.
So basically, I'm trying to automate the tedious task of gathering the data and then adding a bunch of formulas to calculate the fields that we need. here's a snippet of code that performs the above:
Where:
iSampIDCol = Column that I'm testing
i = Column where the R1C1 formula is going
There are about 8 separate calculations that I do. Some of them are more complex, but may still have that formula embeded in them. The above technically works just fine, but a month of data can be about 15K rows. So I've found that it's painfully slow from an automation standpoint.
I've tried to turn of automatic calculations and do the autofill on the last 8 calculated columns all at once, but it doesn't seem to make much of a difference.
I thought that there must be a more efficient way to get this effect in VBA.
Thoughts?
Thanks in advance.
I have a formula in a column that checks to see if a value in another column is unique. It puts 1 if it's the first time it's seen it, and 0 if it isn't unique. Here is the formula:
Code:
=IF(COUNTIFS($A$2:$A2,A2)=1,1,0)
That same logic is also used in other formulas to do some special math to make sure that I only count things once. Normally I could accomplish this with my pivots, but due to the nature of what we are doing, the data model method doesn't work. We also use grouping, and I can't for the life of me understand why you can't do a data model AND grouping.
So basically, I'm trying to automate the tedious task of gathering the data and then adding a bunch of formulas to calculate the fields that we need. here's a snippet of code that performs the above:
Code:
With wsMetrics
.Cells(1, i) = "UniqSamp"
.Cells(2, i).FormulaR1C1 = "=IF(COUNTIFS(R2C" & iSampIDCol & ":RC" & iSampIDCol & ",RC[" & iSampIDCol - i & "])=1,1,0)"
.Cells(2, i).AutoFill Destination:=Range(.Cells(2, i), .Cells(iLastRow, i))
.UsedRange.Value = .UsedRange.Value
End With
Where:
iSampIDCol = Column that I'm testing
i = Column where the R1C1 formula is going
There are about 8 separate calculations that I do. Some of them are more complex, but may still have that formula embeded in them. The above technically works just fine, but a month of data can be about 15K rows. So I've found that it's painfully slow from an automation standpoint.
I've tried to turn of automatic calculations and do the autofill on the last 8 calculated columns all at once, but it doesn't seem to make much of a difference.
I thought that there must be a more efficient way to get this effect in VBA.
Thoughts?
Thanks in advance.