Thread: Loopy Code
View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
cody cody is offline
external usenet poster
 
Posts: 71
Default Loopy Code

The code is running but the values are not being added the the column as
required. I am not sure what is happening. I think we're close though.


"Jef Gorbach" wrote:


"Cody" wrote in message
...
I have four columns I am working with B344:E362. Column B I am trying to
populate based on a list of options from D. Column E is a list of TRUE or
FALSEs based on whether the value should be added to column B. I am trying

a
loop at follows and I don't think I am on the right track.

Dim Check, AddValue
Check = Sheets("Defaults").Range("D344").Value
AddValue = Sheets("Defaults").Range("B344")
Do
If Sheets("Defaults").Range("E344") = True Then
AddValue = Check
Else

End If
Check = Check.Offset(1,0)
Loop Until Check = ""

Thanks for any help


Consider this (untested)

<snip
sheets("defaults").activate
for row = 344 to 362
if trim(ucase(range("e"&row).value)) = "TRUE" then _
range("b"&row).value = range("b"&row).value + range("d"&row).value
next
</end snip

note: if you dont know where the data ends, change the for..next's ending
value to "Range("b65536").end(xlup).row" where column(b) is your longest
data column.