Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 63
Default Type Mismatch

Hi. I get a Type Mismatch run-time error on execution of the following, at
the line commencing "If ..."
Help?? Thanks

Sub TfrData()
Dim wbS As Workbook
Dim wbD As Workbook
Dim wsS As Worksheet
Dim wsD As Worksheet
Dim rD As Range
Dim lrS As Long
Dim lrD As Long
With Application
Set wbS = .Workbooks("ClientList.XLS")
Set wbD = .Workbooks("ClientBase new.xls")
Set wsS = wbS.Worksheets("ClientList")
Set wsD = wbD.Worksheets("Clients")
Set rD = wsD.Range("Number_Range")
lrD = 857
With wsS
For lrS = 2 To 937
If Not Application.Match(.Cells(lrS, 3).Value, rD, 0) Then
lrD = lrD + 1
wsD.Cells(lrD, 13).Value = .Cells(lrS, 2)
wsD.Cells(lrD, 14).Value = .Cells(lrS, 2)
wsD.Cells(lrD, 15).Value = .Cells(lrS, 6)
wsD.Cells(lrD, 16).Value = .Cells(lrS, 1)
wsD.Cells(lrD, 22).Value = .Cells(lrS, 5)
End If 'Not Application.Match(.Cells(lrS, 3).Value, rD, 0)
Next lrS
End With 'wsS
End With 'Application
End Sub 'TfrData()

--
Return email address is not as DEEP as it appears


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Type Mismatch

If Application.Match fails, it returns a variant value containing
an Error subtype value, and you can't use Not with an error
variable. Try changing

If Not Application.Match(.Cells(lrS, 3).Value, rD, 0) Then
' to
If Not IsError(Application.Match(.Cells(lrS,3).Value, rD,0)) Then


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"Jack Schitt" wrote in
message ...
Hi. I get a Type Mismatch run-time error on execution of the

following, at
the line commencing "If ..."
Help?? Thanks

Sub TfrData()
Dim wbS As Workbook
Dim wbD As Workbook
Dim wsS As Worksheet
Dim wsD As Worksheet
Dim rD As Range
Dim lrS As Long
Dim lrD As Long
With Application
Set wbS = .Workbooks("ClientList.XLS")
Set wbD = .Workbooks("ClientBase new.xls")
Set wsS = wbS.Worksheets("ClientList")
Set wsD = wbD.Worksheets("Clients")
Set rD = wsD.Range("Number_Range")
lrD = 857
With wsS
For lrS = 2 To 937
If Not Application.Match(.Cells(lrS, 3).Value, rD, 0) Then
lrD = lrD + 1
wsD.Cells(lrD, 13).Value = .Cells(lrS, 2)
wsD.Cells(lrD, 14).Value = .Cells(lrS, 2)
wsD.Cells(lrD, 15).Value = .Cells(lrS, 6)
wsD.Cells(lrD, 16).Value = .Cells(lrS, 1)
wsD.Cells(lrD, 22).Value = .Cells(lrS, 5)
End If 'Not Application.Match(.Cells(lrS, 3).Value, rD, 0)
Next lrS
End With 'wsS
End With 'Application
End Sub 'TfrData()

--
Return email address is not as DEEP as it appears




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 63
Default Type Mismatch

Thanks, that works (after removing the "Not")

"Chip Pearson" wrote in message
...
If Application.Match fails, it returns a variant value containing
an Error subtype value, and you can't use Not with an error
variable. Try changing

If Not Application.Match(.Cells(lrS, 3).Value, rD, 0) Then
' to
If Not IsError(Application.Match(.Cells(lrS,3).Value, rD,0)) Then


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"Jack Schitt" wrote in
message ...
Hi. I get a Type Mismatch run-time error on execution of the

following, at
the line commencing "If ..."
Help?? Thanks

Sub TfrData()
Dim wbS As Workbook
Dim wbD As Workbook
Dim wsS As Worksheet
Dim wsD As Worksheet
Dim rD As Range
Dim lrS As Long
Dim lrD As Long
With Application
Set wbS = .Workbooks("ClientList.XLS")
Set wbD = .Workbooks("ClientBase new.xls")
Set wsS = wbS.Worksheets("ClientList")
Set wsD = wbD.Worksheets("Clients")
Set rD = wsD.Range("Number_Range")
lrD = 857
With wsS
For lrS = 2 To 937
If Not Application.Match(.Cells(lrS, 3).Value, rD, 0) Then
lrD = lrD + 1
wsD.Cells(lrD, 13).Value = .Cells(lrS, 2)
wsD.Cells(lrD, 14).Value = .Cells(lrS, 2)
wsD.Cells(lrD, 15).Value = .Cells(lrS, 6)
wsD.Cells(lrD, 16).Value = .Cells(lrS, 1)
wsD.Cells(lrD, 22).Value = .Cells(lrS, 5)
End If 'Not Application.Match(.Cells(lrS, 3).Value, rD, 0)
Next lrS
End With 'wsS
End With 'Application
End Sub 'TfrData()

--
Return email address is not as DEEP as it appears






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
Type mismatch... George[_4_] Excel Discussion (Misc queries) 7 December 19th 07 12:20 PM
type mismatch--how to fix rroach Excel Discussion (Misc queries) 2 July 14th 05 06:23 PM
Type mismatch Patti[_5_] Excel Programming 3 May 30th 04 02:44 PM
Type mismatch Steve Garman Excel Programming 0 February 5th 04 07:39 AM
Type Mismatch Phil Hageman[_3_] Excel Programming 2 January 9th 04 06:11 PM


All times are GMT +1. The time now is 05:07 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"