3 Attachment(s)
[RESOLVED] Corect runtime error in matching columns
Hello guys I have got following code,
the code check column A and B in sheet1 then match them with sheet2 A and B,
Sheet1
Attachment 128869
Sheet2
Attachment 128871
if column A and B sheet1 match column a and B in sheet2,
take the matching cell in this result,
sheet 1 same row column J the value * the value in column G same row sheet2,
but if there are cells in sheet1 and column A and B that not exists in Sheet2,
I get this error
Runtime error 13 : incompatible types
See attached file.Attachment 128873
Could someone help me ?
Thank you in advance
Re: Corect runtime error in matching columns
what's your code to do the matching?
Re: Corect runtime error in matching columns
Quote:
Originally Posted by
vbfbryce
what's your code to do the matching?
sorry my mistake,
see attachment
Re: Corect runtime error in matching columns
I don't get any errors when I run your code as is. However, you should change this:
Code:
Set ws1 = ActiveSheet
to this:
Code:
Set ws1 = Worksheets("sheet1")
in case Sheet2 is active when you run the code. Making that change did not yield any errors, either.
Re: Corect runtime error in matching columns
while the code ran without error i am not sure it would matching correctly, a single run matches the following rows
1 1
1 6
6 1
6 6
though mystring always gets its value from sheet2 at the current row in sheet1, which is probably not the desired result
as you have already set worksheet objects, you should avoid going back to the individual sheets, just work with the objects
Re: Corect runtime error in matching columns
Most likely, when you thought that you deleted a value, you typed a " " instead of hitting the delete key. This is the peril of freely treating text and numbers as the same thing. If you must, then at least perform a IsNumeric(var) check before performing any numeric computations with the value.
1 Attachment(s)
Re: Corect runtime error in matching columns