Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi, Im having problems at the 'Else If' line, help is much appreciated, Teresa
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\Team.xls") vArr = Array("Hudson", "John", "Jim") 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 rCell.Offset(0,3)= "CC" Then rCell.EntireRow.Copy Destination:=fin.Worksheets("Other").Cells( _ 25, 1).End(xlUp).Offset(1, 0) Exit For End If Next i End With Next rCell |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
try removing rCell as it is already referenced by the with statement.
Else If .Offset(0,3)= "CC" Then ..EntireRow.Copy You might want to expand on what sort of problem you are having also.... Hth, OJ |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Teresa,
What problem are you getting? -- HTH Bob Phillips "teresa" wrote in message ... Hi, Im having problems at the 'Else If' line, help is much appreciated, Teresa 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\Team.xls") vArr = Array("Hudson", "John", "Jim") 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 rCell.Offset(0,3)= "CC" Then rCell.EntireRow.Copy Destination:=fin.Worksheets("Other").Cells( _ 25, 1).End(xlUp).Offset(1, 0) Exit For End If Next i End With Next rCell |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Bob, Ive created a new thread for this 'Object Required' which details the
issue. Many Thanks "Bob Phillips" wrote: Teresa, What problem are you getting? -- HTH Bob Phillips "teresa" wrote in message ... Hi, Im having problems at the 'Else If' line, help is much appreciated, Teresa 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\Team.xls") vArr = Array("Hudson", "John", "Jim") 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 rCell.Offset(0,3)= "CC" Then rCell.EntireRow.Copy Destination:=fin.Worksheets("Other").Cells( _ 25, 1).End(xlUp).Offset(1, 0) Exit For End If Next i End With Next rCell |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Colon at the end of excel file name(ex: problem.xls:1, problem.xls | New Users to Excel | |||
Started out as an Access problem. Now an Excel problem | Excel Discussion (Misc queries) | |||
problem with a conditional max problem | Excel Discussion (Misc queries) | |||
Problem when multipple users access shared xl-file at the same time, macrocode for solve this problem? | Excel Programming |