View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy[_13_] Tom Ogilvy[_13_] is offline
external usenet poster
 
Posts: 1
Default VBA newb needing help with an IF

whoops, try this instead. I am not sure what range 2 - 13 means

Assume us column B to determine the extent of your data

Assume destination is Book2.xls, first worksheet.

Sub CopyTrueRows()
Dim cell1 as Range, bCopy as boolean
Dim rng as Range, cell as Range
set rng = Range(Cells(1,2),Cells(row.count,2).end(xlup))

for each cell in rng
bCopy = false
for each cell1 in cell.Resize(1,6)
if cell1 = True then
bCopy = True
exit for
end if
Next
if bCopy then
cell.EntireRow.copy Destination:= _
workbooks("Book2.xls").Worksheets(1) _
..Cells(rows.count,1).end(xlup)
end if
Next

End Sub


If it means columns 2 to 13

Sub CopyTrueRows()
Dim cell1 as Range, bCopy as boolean
Dim rng as Range, cell as Range
set rng = Range(Cells(1,2),Cells(row.count,2).end(xlup))

for each cell in rng
bCopy = false
for each cell1 in cell.Resize(1,6)
if cell1 = True then
bCopy = True
exit for
end if
Next
if bCopy then
cell.Resize(1,12).copy Destination:= _
workbooks("Book2.xls").Worksheets(1) _
..Cells(rows.count,1).end(xlup)
end if
Next

End Sub



--
regards,
Tom Ogilvy


---
Message posted from http://www.ExcelForum.com/