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

Hi,

I'm trying to write VBA code to copy and paste special values. I'm
using lookup formula in sheet1 only the values to be copied to be
copied to sheet3 In sheet1 if the lookup condition is satisfied it
gives the value otherwise it displays #N/A.
My syntax is like this

For Each c3 In Worksheets("calculation").Range("c24:c1203")
If c3.Value < #N/A Then
c3.Copy
Worksheets("result").Range(c3.Address).PasteSpecia l Paste:=xlValues
Worksheets("result").Range(c3.Address).PasteSpecia l Paste:=xlFormats
End If
Next c3

But while executing it is giving me the error Type mismatch and
stopping the code. Is there any suggestion pl. Tell me.

Thanks and Regards

Ramana

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 414
Default Type Mismatch error in VBA code

Maybe:

For Each c3 In Worksheets("calculation").Range("c24:c1203")
If c3.Text < "#N/A" Then
c3.Copy
Worksheets("result").Range(c3.Address).PasteSpecia l Paste:=xlValues
Worksheets("result").Range(c3.Address).PasteSpecia l Paste:=xlFormats
End If
Next c3

Hope this helps
Rowan

bobby wrote:
Hi,

I'm trying to write VBA code to copy and paste special values. I'm
using lookup formula in sheet1 only the values to be copied to be
copied to sheet3 In sheet1 if the lookup condition is satisfied it
gives the value otherwise it displays #N/A.
My syntax is like this

For Each c3 In Worksheets("calculation").Range("c24:c1203")
If c3.Value < #N/A Then
c3.Copy
Worksheets("result").Range(c3.Address).PasteSpecia l Paste:=xlValues
Worksheets("result").Range(c3.Address).PasteSpecia l Paste:=xlFormats
End If
Next c3

But while executing it is giving me the error Type mismatch and
stopping the code. Is there any suggestion pl. Tell me.

Thanks and Regards

Ramana

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Type Mismatch error in VBA code

Hi there,

Try using the iserror function:

For Each c3 In Worksheets("calculation").Range("c24:c1203")
If iserror(c3.Text) Then
c3.Copy
Worksheets("result").Range(c3.Address).PasteSpecia l Paste:=xlValues
Worksheets("result").Range(c3.Address).PasteSpecia l Paste:=xlFormats
End If
Next c3

Caveat, though... this doesn't only pick up the #N/A error. It will trigger
on the Div/0, Name and any others as well.

Ken Puls
www.officearticles.com

"bobby" wrote in message
oups.com...
Hi,

I'm trying to write VBA code to copy and paste special values. I'm
using lookup formula in sheet1 only the values to be copied to be
copied to sheet3 In sheet1 if the lookup condition is satisfied it
gives the value otherwise it displays #N/A.
My syntax is like this

For Each c3 In Worksheets("calculation").Range("c24:c1203")
If c3.Value < #N/A Then
c3.Copy
Worksheets("result").Range(c3.Address).PasteSpecia l Paste:=xlValues
Worksheets("result").Range(c3.Address).PasteSpecia l Paste:=xlFormats
End If
Next c3

But while executing it is giving me the error Type mismatch and
stopping the code. Is there any suggestion pl. Tell me.

Thanks and Regards

Ramana



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Type Mismatch error in VBA code

Hi,

Thanks to all.

Rgds

Ramana

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
Visual Basic Error Run Time Error, Type Mismatch Meg Partridge Excel Discussion (Misc queries) 12 September 10th 08 06:10 PM
Help: Compile error: type mismatch: array or user defined type expected lvcha.gouqizi Excel Programming 1 October 31st 05 08:20 PM
[Q] Save As throws type mismatch error in control's code? Jason Weiss Excel Discussion (Misc queries) 1 July 16th 05 04:21 AM
Befuddled with For Next Loop ------ Run - Time Error '13' Type Mismatch Error rdavis7408 Excel Programming 1 August 25th 04 03:54 AM
type mismatch in this code Jay Baxter Excel Programming 4 February 26th 04 06:36 PM


All times are GMT +1. The time now is 05:39 PM.

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

About Us

"It's about Microsoft Excel"