Answers for "loop through named range vba"

4

vba excel range loop

'Define variables
Dim range as range
Dim cell as range

'Define your range in your worksheet
Set range = Sheets("Example").range("A1:A5")

'Loop through every cell in our defined range (range1)
For each cell in range
	'Every value for each cell in range ("A1:A5") will be "Test1"
	cell.value = "Test1"
 	'Every value for each cell in range ("B1:B5") will be "Test2"
    cell.offset(0,1).value = "Test2"
    'Every value for each cell in range ("C1:C5") will be "Test3"
    cell.offset(0,2).value = "Test3"
Next cell
Posted by: Guest on July-05-2021

Browse Popular Code Answers by Language