Is there a way to express variable f as a range of numbers like for instance, f = 4 to 9 in excel vba? Because my intention here is to create a condition such that for i = 1 to lastColumn, if i falls into the range 4 to 9, as such it will scan through values from i to lastcolumn and accept headers(voltage,power and time) that lies within from cells(1,4) to cells(1,9) and after that the private sub voltagepowertime will be called where it creates multiple pivottables by using the columns of voltage, power and time when their headers are being detected at the first row. I will also be grateful if there are others way to express my intention here.
Dim sh as Worksheet
Dim LastColumn as integer
Dim f as integer
f=4 to 9 '------>How to express f as a range of number?
For i = 1 to LastColumn
if i = f Then
if sht.Cells(1,f).Value = "Voltage" And sht.Cells(1,f).Value= "Power" and sht.Cells(1,f).Value= "Time" Then
Call voltagepowertime