Thread
:
Variable results to new workbook
View Single Post
#
1
Posted to microsoft.public.excel.programming
Fred[_20_]
external usenet poster
Posts: 5
Variable results to new workbook
I have managed to get the below code working perfect. But for the life
of me I can not figure out how to get the results into a new workbook.
The line "Debug.Print i, myNumbers(i)" sends it to the imediate window
but I need it to go to a new workbook.
Another thing I would like to do is prompt for the file names. These
should be easy but I am stumped!!
Thanks!!
Fred
-----------
Sub compare()
Dim i As Long
Dim myNumbers()
ReDim myNumbers(1 To 1)
With Workbooks("work1.xls").Sheets("Sheet1")
Set rng1 = .Range(.Range("A2"), .Range("A2").End(xlDown))
End With
With Workbooks("work2.xls").Sheets("Sheet1")
Set rng2 = .Range(.Range("A2"), .Range("A2").End(xlDown))
End With
i = 1
For Each cell In rng1
res = Application.Match(cell.Value, rng2, 0)
If IsError(res) Then
myNumbers(i) = cell.Value
i = i + 1
ReDim Preserve myNumbers(1 To i)
End If
Next
ReDim Preserve myNumbers(1 To i - 1)
For i = LBound(myNumbers) To UBound(myNumbers)
Debug.Print i, myNumbers(i)
Next i
End Sub
-------------
Reply With Quote
Fred[_20_]
View Public Profile
Find all posts by Fred[_20_]