Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Newsgroup Archive
Excel Newsgroups
Excel Misc
VBA Formula Help
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
Reply to thread
Message
[QUOTE="Dave Peterson, post: 3284562"] You don't really work with data in a workbook--you (or at least I) work with data on a worksheet. Since your code is in Test-Tracker.xls, we can use ThisWorkbook. #1. What worksheet holds the data in column B of that test-tracker.xls worksheet? #2. Where does the data start (B1 or B2 or B4)???? Maybe... Option Explicit Sub myMatch() Dim res As Variant Dim fName As Variant Dim TempWkbk As Workbook Dim TrackWks As Worksheet Dim AcctWks As Worksheet Dim AcctRng As Range Dim myCell As Range Dim myRng As Range Set TrackWks = ThisWorkbook.Worksheets("SomeSheetNameHere") fName = Application.GetOpenFilename() If fName = False Then 'user hit cancel Exit Sub End If Set TempWkbk = Workbooks.Open(Filename:=fName, ReadOnly:=True) TempWkbk.Worksheets("Accounting_Teams").Copy _ Before:=ThisWorkbook.Sheets(1) Set AcctWks = ThisWorkbook.Sheets(1) 'the newly pasted sheet Set AcctRng = AcctWks.Range("C:C") TempWkbk.Close savechanges:=False With TrackWks Set myRng = .Range("B4", .Cells(.Rows.Count, "B").End(xlUp)) End With For Each myCell In myRng.Cells If myCell.Value = "" Then 'do nothing Else res = Application.Match(myCell.Value, AcctRng, 0) If IsError(res) Then 'no match, ignore Else AcctWks.Cells(res, "T").Copy _ Destination:=TrackWks.Cells(myCell.Row, "N") End If End If Next myCell 'do you want to keep that accounting worksheet? Application.DisplayAlerts = False AcctWks.Delete Application.DisplayAlerts = True End Sub [/QUOTE]
Verification
Post reply
Forums
Archive
Newsgroup Archive
Excel Newsgroups
Excel Misc
VBA Formula Help
Top