LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 169
Default Invalid Next Control Variable Reference

I get an 'Invalid Next Control Variable Reference', also is there
a ore efficient way of doing this rather than re-defining:
fin,fin2,vArr,vArr2 etc.etc.
Many Thanks

Public Sub coiD()
Dim fin As Workbook
Dim fin2 As Workbook
Dim vArr As Variant
Dim vArr2 As Variant
Dim rCell As Range
Dim rDest As Range
Dim sDest As Range
Dim i As Long
Dim j As Long

Set fin = Application.Workbooks.Open( _
"C:\My Documents\Business Plans\TeamC.xls")
Set fin2 = Application.Workbooks.Open( _
"C:\My Documents\Business Plans\TeamM.xls")
vArr = Array("Hudson", "HSB", "C&W")
vArr2 = Array("ACCEN", "AME", "SHEL")

For Each rCell In Range("D1:D" & _
Range("D" & Rows.Count).End(xlUp).Row)
With rCell
For i = LBound(vArr) To UBound(vArr)
For j = LBound(vArr2) To UBound(vArr2)
If .Value = vArr(i) Then
Set rDest = fin.Worksheets(vArr(i)).Cells( _
25, 1).End(xlUp).Offset(1, 0)
.EntireRow.Copy
Destination:=rDest

If .Value = vArr2(j) Then
Set sDest = fin2.Worksheets(vArr2(j)).Cells( _
25, 1).End(xlUp).Offset(1, 0)
.EntireRow.Copy Destination:=sDest

Exit For
Exit For
End If
End If
Next i
Next j
End With
Next rCell
End Sub


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Invalid cell reference Grey Old Man[_2_] Excel Discussion (Misc queries) 1 April 26th 10 02:47 PM
Invalid Reference in Chart Sam Charts and Charting in Excel 1 October 24th 08 04:57 PM
Invalid Reference Message? Ken Excel Discussion (Misc queries) 1 February 12th 07 09:12 PM
How do I fix an Invalid Reference? Nic New Users to Excel 1 June 1st 06 04:43 PM
Variable Reference to a Form Control Sharlene England Excel Programming 2 November 5th 04 10:56 PM


All times are GMT +1. The time now is 12:50 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"