Computing.Net > Forums > Programming > Excel VB problem. Type Mismatch

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Excel VB problem. Type Mismatch

Reply to Message Icon

Name: hydrodog
Date: December 17, 2007 at 02:12:49 Pacific
OS: XP
CPU/Ram: 2Ghtz \ 1.5 GB
Product: -
Comment:

I'm running a vbscript in excel.
But i keep running into
Run-time error '13':
Type mismatch

at line
If Cells(i, 2).Value = "#N/A" Then Cells(i, 2).Value = Cells(i - 1, 2).Value

Any1 have any idea how to settle this problem?

Sub Test()


Sheets("Sheet1").Select
Range("A2").Select
Selection.Copy

Sheets("Sheet2").Select
Range("A1").Select
ActiveSheet.Paste

'Column A
For i = 1 To 1000
Cells(i, 1) = Range("A1").Value + i - 1
Next i

'Column B
Worksheets("Sheet2").Range("B1:B1000").Formula = "=VLOOKUP(Sheet2!A1,Sheet1!A:A,1,False)"

'Replace #N/A value with value above
For i = 1 To 1000
If Cells(i, 2).Value = "#N/A" Then Cells(i, 2).Value = Cells(i - 1, 2).Value
Next i

End Sub



Sponsored Link
Ads by Google

Response Number 1
Name: Razor2.3
Date: December 17, 2007 at 08:46:37 Pacific
Reply:

If Worksheetfunction.IsNA(Cells(i, 2)) Then _
Cells(i, 2).Formula = Cells(i - 1, 2).Value


0
Reply to Message Icon

Related Posts

See More


bat script (simple) how do you delete system ...



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Excel VB problem. Type Mismatch

VB Problem in addNew www.computing.net/answers/programming/vb-problem-in-addnew/7183.html

Type Mismatch error www.computing.net/answers/programming/type-mismatch-error/14050.html

VB problem different language of Window www.computing.net/answers/programming/vb-problem-different-language-of-window/2878.html