In Excel VBA, I created a code for a data table that had 12,500 rows. Later, I found the same code would be valuable for data tables with different sizes.
To make it easier, I converted all of the ranges into strings, so that I would only need to change the strings at the top of the code once, instead of each time the range was referenced.
This small piece of the code has an example. By declaring "Group_key" at the top, that range would automatically flow into the code. I did this for about 30 ranges, but there is one range I can't figure out.
In the "COUNTIF" equation, it references a relative range. I would like to convert "R6C2:R12500C2" into a string, but when I tried that, it automatically included quotes around the range, and the COUNTIF function doesn't work.
Would anyone know how to solve this?
Sub Format()
Dim Group_key As String
Group_key = "A5:A12500"
Range("AT6").Select
Selection.NumberFormat = "General"
ActiveCell.FormulaR1C1 = "=COUNTIF(R6C2:R12500C2,RC[-44])"
Selection.AutoFill Destination:=Range(Group_key)
End Sub