Thread: Complex problem
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips Bob Phillips is offline
external usenet poster
 
Posts: 10,593
Default Complex problem

Sub Test()
Dim iLastRow As Long
Dim iNextRow As Long
Dim i As Long

iLastRow = Cells(Rows.Count, "G").End(xlUp).Row
For i = 1 To iLastRow
If Cells(i, "G").Value = 50 Then
With Workbooks("Book2").Worksheets(1)
iNextRow = .Cells(Rows.Count, "A").End(xlDown).Row + 1
.Cells(iNextRow, "A").Value = Cells(i, "A").Value
.Cells(iNextRow, "B").Value = Cells(i, "D").Value
.Cells(iNextRow, "C").Value = Cells(i, "G").Value
'etc.
End With
End If
Next i

End Sub


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"bpotter" wrote in message
oups.com...
I am trying to create a macro that looks in column G. If the value in
colum column G is greater than or equal to 50 then I want the macro to
take certain parts of the line and puts into another workbook. I have
about 50 lines that I need it to look through and then quit. How would
I go about starting this? I am decent with macros but I am stumped on
this. Also when I add these lines into the other workbook how do I add
lines instead of just copying and paste. I would appreciate any help at
all thank you!!!