Hi,
My below code is working fine but I want to optimize it using a loop. Can I re-write below code using any loop in VBA?
Your help is appreciated. Thank you
My below code is working fine but I want to optimize it using a loop. Can I re-write below code using any loop in VBA?
Code:
Set rng2 = ws.Range("O14:O500")
Set rng3 = ws.Range("P14:P500")
Set rng4 = ws.Range("Q14:Q500")
Set rng5 = ws.Range("R14:R500")
Set rng6 = ws.Range("S14:S500")
Range("O14").Value = Application.WorksheetFunction.Sum(rng2.SpecialCells(xlCellTypeVisible))
Range("P14").Value = Application.WorksheetFunction.Sum(rng3.SpecialCells(xlCellTypeVisible))
Range("Q14").Value = Application.WorksheetFunction.Sum(rng4.SpecialCells(xlCellTypeVisible))
Range("R14").Value = Application.WorksheetFunction.Sum(rng5.SpecialCells(xlCellTypeVisible))
Range("S14").Value = Application.WorksheetFunction.Sum(rng6.SpecialCells(xlCellTypeVisible))
Your help is appreciated. Thank you