I have a number of reports that I am pulling information from and then placing into new fields. I'm wondering if there's a good way to strucutre it so that, depending on the report type, variables are dimmed to reference the cells that I need, but with the loop counter built-in. Here is a quick mock-up of what I'm looking for:
sub demo()
dim i as long
dim a,b,c,d,e as range
for i = 1 to 100
if cells(i,1).value2 like "Financials-Q4" Then
set a = cells(i,21).value2
set b = cells(i,44).value2
set c = cells(i,65).value2
elseif cells(i,1).value2 like "Amor-Q4" Then
set a = cells(i,100).value2
set b = cells(i,97).value2
set c = cells(i,157).value2
set d = cells(i,89).value2
end if
next i
'Start using variables
for i = 1 to 100
If a = b Then
c = "Does not compute"
Else
c = "Does compute"
End if
next i
Currently my code is basically just referencing each individual cell value which is extremely time consuming to clean up / change around.