I am writing an application in VBA for excel. Using some conditions and counting the number of records by the following functions which is working fine.
cnt = appExcel.Application.CountIfs(R1, AuditType, R2, "Fail", UserRange1, UserName & "*")
Here R1,R2 and UserRange1 are Range types which is describing individual cells.
If we print
R1.Address '$E:$E
R2.Address ' $M:$M so on.
I am getting the number of rows present with those criteria in “cnt” variable.
I need further manipulation like searching some custom cells from the above range of cells. To do that I need to store those addresses in a “Range” object.
Please guide me how can I store those filtered records in a range. I don’t want to copy to another area also.
You add a new range to a worksheet by declaring a Name object in VBA and then setting it’s RefersTo value to the address. This example adds the needed declarations and code to do this. It assumes that you are interested in the cells in your R1 range which contain constants: