View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
RominallL RominallL is offline
external usenet poster
 
Posts: 26
Default Reference columns using For each r in currentregion

I've tried using this for an if then type scenario but I get hung up trying
to reference the columns.
Something like

for each r in currentregion
If cell("A"+R+"").value = 6 then
cell( ---A + 6 columns-----).value = '=sum(A"+r+" / 6)'
Elseif cell("A"+r+"").value = "" then
cells(A"+r+":AA"+r+"").value = 3
Else
cells(A"+r+":BA"+r+"").value = '=sum(A" -------r minus 1
row--------" + A" + ---------r plus 3 rows-------")
end if
next r

There's more formula stuff that goes into it, but I can't seem to get the
row/column reference correct.

I will never know the exact column or row references prior to the begining
of code exectution. Right now I'm doing a select current region, count rows
and columns and then doing some really combersome variable declarations. Any
way to make it tighter?