![]() |
Iterating through row cells on column Match, help please.
Now getting a 2024, Type Mismatch error in this line: res =
Application.Match(vName, xlRng2, 0) There is a match for the first name that is picked up on the second sheet, so I don't know why the error. Thanks And is there some reason you're starting a new instance of excel? If no, you could do all your work within the current instance: Option Explicit Sub DoReport() Application.ScreenUpdating = False Dim xlWB1 As Excel.Workbook Dim xlWB2 As Excel.Workbook Dim xlRng2 As Excel.Range Dim res As Variant Dim i As Integer Dim j As Integer Dim lNameLoop As Integer Dim vName As String Dim vCalls As Integer Set xlWB1 = Workbooks.Open("C:\PerfSumm\PerfSumm1.tab") Set xlWB2 = Workbooks.Open("C:\PerfSumm\TheReport.xls") Set xlRng2 = Worksheets(2).Range("a1:a100") For lNameLoop = 1 To 100 vName = xlWB1.Sheets(1).Cells(lNameLoop, "A").Value vCalls = xlWB1.Worksheets(1).Cells(lNameLoop, "B").Value res = Application.Match(vName, xlRng2, 0) If IsError(res) Then 'not found Else If IsEmpty(xlRng2(res).Offset(0, 1)) Then xlRng2(res).Offset(0, 1).Value = vCalls ElseIf IsEmpty(xlRng2(res).Offset(0, 2)) Then xlRng2(res).Offset(0, 2).Value = vCalls Else xlRng2(res).End(xlToRight).Offset(0, 1).Value = vCalls End If End If Next lNameLoop Application.ScreenUpdating = True End Sub |
All times are GMT +1. The time now is 04:04 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com