View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Jim Thomlinson Jim Thomlinson is offline
external usenet poster
 
Posts: 5,939
Default VBA Coding Question

This is really generic but it should get you started...

dim rngToSearch as range
dim rng as range

with sheets("Sheet1")
set rngtosearch = .range(.range("D2"), .cells(rows.count, "D").end(xlUp))
end with

for each rng in rngtosearch
select case rng.value
Case 1,2
msgbox "Do This"
Case 3,4
msgbox "Do that"
Case Else
msgbox "Where am I and why am I in this handbasket"
End Select
next rng

--
HTH...

Jim Thomlinson


"Matt" wrote:

I'm trying to write some VBA code that will add formulas to specific rows in
an excel spreadsheet. The formulas will be determined by a code in a
seperate column. For example, current location is a cell in column "H":

If the value in column "D" = 2 then
sum all conitiguos cells above (akin to clicking on the summation symbol)
and
copy the formula to the last column to the right that has values then
move down
one row and repeat.

If the value in column "D" = 4 then
subtract the value one row above from the value two rows above and
copy the
formula to the last column to the right that has values then move down
one
row and repeat

If the value in column "D" = 6 then
Go to Home
EndIf

EndIf

EndIf


Any suggestions...?

Thanks