Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How can find match of one cell from a column of cells? | Excel Discussion (Misc queries) | |||
Formula that will change subsequent cells in a column to match fir | Excel Discussion (Misc queries) | |||
Format cell to match cells below in same column | Excel Discussion (Misc queries) | |||
Copying a column to a new sheet so that cells match. | Excel Worksheet Functions | |||
iterating checkboxes | Excel Discussion (Misc queries) |