#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 71
Default Loopy Code

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 226
Default Loopy Code

If you are wanting to copy the value from column D to column B where column E
is true then you could do it like this:

Sub Loopy()
Dim lRow As Long
Dim Cell As Range
Dim chkRange As Range
lRow = Cells(Rows.Count, 5).End(xlUp).Row
Set chkRange = Range(Cells(344, 2), Cells(lRow, 2))
For Each Cell In chkRange
If Cell.Offset(0, 3).Value Then
Cell.Value = Cell.Offset(0, 2).Value
End If
Next Cell
End Sub

Of course if that is what you are wanting to do then you could just enter
the formula =IF(E344,D344,"") in B344 and copy it down.

Hope this helps
Rowan

"Cody" wrote:

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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 59
Default Loopy Code


"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.






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 71
Default Loopy Code

This code is returning the value of cell B343 and not completing the
remainder of the list. I don't follow some of the code and I am busy with
"Help" right now working on it. If I figure out the problem I will let you
know.

Thanks for any help.



"Rowan" wrote:

If you are wanting to copy the value from column D to column B where column E
is true then you could do it like this:

Sub Loopy()
Dim lRow As Long
Dim Cell As Range
Dim chkRange As Range
lRow = Cells(Rows.Count, 5).End(xlUp).Row
Set chkRange = Range(Cells(344, 2), Cells(lRow, 2))
For Each Cell In chkRange
If Cell.Offset(0, 3).Value Then
Cell.Value = Cell.Offset(0, 2).Value
End If
Next Cell
End Sub

Of course if that is what you are wanting to do then you could just enter
the formula =IF(E344,D344,"") in B344 and copy it down.

Hope this helps
Rowan

"Cody" wrote:

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

  #5   Report Post  
Posted to microsoft.public.excel.programming
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.







Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
split post code (zip code) out of cell that includes full address Concord Excel Discussion (Misc queries) 4 October 15th 09 06:59 PM
Drop Down/List w/Code and Definition, only code entered when selec Spiritdancer Excel Worksheet Functions 2 November 2nd 07 03:57 AM
Loopy? AnthonyG Excel Worksheet Functions 2 January 16th 06 01:54 PM
Create a newworksheet with VBA code and put VBA code in the new worksheet module ceshelman Excel Programming 4 June 15th 05 04:37 PM
stubborn Excel crash when editing code with code, one solution Brian Murphy Excel Programming 0 February 20th 05 05:56 AM


All times are GMT +1. The time now is 09:04 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"