Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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

Reply
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
How can find match of one cell from a column of cells? mat Excel Discussion (Misc queries) 1 October 26th 06 04:59 PM
Formula that will change subsequent cells in a column to match fir Scott B Excel Discussion (Misc queries) 1 March 31st 06 12:19 AM
Format cell to match cells below in same column bakes1 Excel Discussion (Misc queries) 1 March 1st 06 07:01 PM
Copying a column to a new sheet so that cells match. Nadeem Excel Worksheet Functions 0 October 11th 05 02:03 PM
iterating checkboxes [email protected] Excel Discussion (Misc queries) 1 May 11th 05 08:42 PM


All times are GMT +1. The time now is 09:03 AM.

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

About Us

"It's about Microsoft Excel"