Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
This macro is attempting to perform the following:
If a value in D Col is in the array then the line is copied to the associated worksheet. However if the value isnt in the array but the G Col value is "CC", then line should be copied to "WP" worksheet, If neither condition holds but H Col value is XY then copies line to "Other" Worksheet Its with the two else statements that Im having problems, my last error message was 'Object Required' Many Thanks Public Sub coiD() Dim fin As Workbook Dim vArr As Variant Dim rCell As Range Dim rDest As Range Dim i As Long Set fin = Application.Workbooks.Open( _ "C:\My Documents\Business Plans.xls") vArr = Array("Hudson", "HS", "C&W") For Each rCell In Range("D1:D" & _ Range("D" & Rows.Count).End(xlUp).Row) With rCell For i = LBound(vArr) To UBound(vArr) If .Value = vArr(i) Then Set rDest = fin.Worksheets(vArr(i)).Cells( _ 25, 1).End(xlUp).Offset(1, 0) 'If rDest.Row < 18 Then _ ' Set rDest = rDest.Offset(18 - rDest.Row, 0) .EntireRow.Copy Destination:=rDest Else: If .Offset(0, 3).Value = "CC" Then EntireRow.Copy _ Destination:=fin.Worksheets("WP").Cells(25, 1).End(xlUp).Offset(1, 0) Else: If .Offset(0, 4).Value = "XY" Then EntireRow.Copy _ Destination:=fin.Worksheets("Other").Cells(25, 1).End(xlUp).Offset(1, 0) Exit For End If Next i End With Next rCell End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
R/T 424 - Object required Help | Excel Discussion (Misc queries) | |||
Object Required | Excel Discussion (Misc queries) | |||
Object required? | Excel Programming | |||
Object required? | Excel Programming | |||
Object required. | Excel Programming |