ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Complex problem (https://www.excelbanter.com/excel-programming/373830-complex-problem.html)

bpotter

Complex problem
 
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!!!


Bob Phillips

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!!!




bpotter

Complex problem
 
Thank you very much!!!! I will try that!


bpotter

Complex problem
 
Here is my code. Now I am getting an error. (Method or Data Member not
found)

Sub problemwells()

Dim wsPDI As Worksheet
Dim wsTodays As Worksheet
Dim wsPWS As Worksheet
Dim wbProblems As Workbook
Dim wsRt105 As Worksheet

Set wsPDI = ThisWorkbook.Sheets("PDI Paste Here")
Set wsTodays = ThisWorkbook.Sheets("Today's ")
Set wsPWS = ThisWorkbook.Sheets("Problem Well Sort")

Set wbProblems = Workbooks.Open("C:\Documents and
Settings\bpotter\Desktop\Problem Well File\Problem Wells for
Routes.xls")
Set wsRt105 = wbProblems.Sheets("Route 105")

Dim iLastRow As Long
Dim iNextRow As Long
Dim i As Long

iLastRow = Cells(Rows.Count, "U").End(xlUp).Row
For i = 1 To iLastRow
If Cells(i, "U").Value = 50 Then
With ThisWorkbook.wsPWS
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

End With
End If
Next i






End Sub



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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com