# Run Type error 13 Type Mismatch

1. ## Run Type error 13 Type Mismatch

Hi All,

I am writing a VBA code to calculate and track the corrosion defects in subsea pipelines the intention is to input the data from ROV scans and then do various mathematical calculations and then output them back into the excel spreadsheet.

When I run the code I get the following error.....

Error: Run type error '13' Type Mismatch

The debug says that the following line is defective.

'final calculation

ReDim Sfailurearray(1 To RowCount, 1 To ColCount)
For i = 1 To RowCount
For j = 1 To ColCount
Sfailurearray = FlowStress * (TopFailurearray(i, j) / BottomFailurearray(i, j))
Next j
Next i

Mathematically I have traced the "root-cause" of the problem back to the if function that is below.

ReDim RealDeptharray1(1 To RowCount, 1 To ColCount)
For i = 1 To RowCount
For j = 1 To ColCount
RealDeptharray1(i, j) = Deptharray(i, j) + ((accRel / 100) * (Deptharray(i, j)))
Next j
Next i

ReDim RealDeptharray2(1 To RowCount, 1 To ColCount)
For i = 1 To RowCount
For j = 1 To ColCount
RealDeptharray2(i, j) = Deptharray(i, j) + accAbs
Next j
Next i

ReDim RealDeptharray(1 To RowCount, 1 To ColCount)
For i = 1 To RowCount
For j = 1 To ColCount
If OptionButton6.Value = True Then
RealDeptharray(i, j) = RealDeptharray1(i, j)
End If
Next j
Next i

ReDim RealDeptharray(1 To RowCount, 1 To ColCount)
For i = 1 To RowCount
For j = 1 To ColCount
If OptionButton7.Value = True Then
RealDeptharray(i, j) = RealDeptharray2(i, j)
End If
Next j
Next i

The idea is that if option button 6 is ticked then the "relative" or the "absolute" depth calculation is used to calculate the real defect depth and then a different "realdepth" value is used.

Any help is appreciated. If anyone needs any more information on my method or what I am trying to achieve then please do not hesitate to let me know.

Thank you very much for your help,

Best Regards,

Affan Khan

2. ## Re: Run Type error 13 Type Mismatch

Affan

Which particular line(s) is causing the error?

What type of Option button is it, Forms or ActiveX?

Does it have a linked cell?

3. ## Re: Run Type error 13 Type Mismatch

I think its Activex but I am not sure. I tried using the code tags I dont know why they havent worked...

'final calculation

ReDim Sfailurearray(1 To RowCount, 1 To ColCount)
For i = 1 To RowCount
For j = 1 To ColCount
Sfailurearray = FlowStress * (TopFailurearray(i, j) / BottomFailurearray(i, j))
Next j
Next i

5. ## Re: Run Type error 13 Type Mismatch

Mathematically I have traced the "root-cause" of the problem back to the if function that is below.

6. ## Re: Run Type error 13 Type Mismatch

Forum Moderator:
I applologise if the tags are not working i am trying to post the code with the tags

9. ## Re: Run Type error 13 Type Mismatch

Affan

I thinK I'm being thick but it's still not clear which line of code is the problem.

You say it's the If, but there are 2 Ifs.

Could you attach a sample workbook?

Hopefully that will clarify things.

10. ## Re: Run Type error 13 Type Mismatch

is there any way to attach the excel file?

11. ## Re: Run Type error 13 Type Mismatch

Click Go Advanced then scroll down and click Manage attachements.

There should now be a window you can use to select and upload files.

12. ## Re: Run Type error 13 Type Mismatch

can you seee the file?

13. ## Re: Run Type error 13 Type Mismatch

No, I'm afraid not.

Here's a more detailed guide to attaching a file.

To Attach a File:

2. In the frame Attach Files you will see the button Manage Attachments
3. Click the button.
4. A new window will open titled Manage Attachments - Excel Forum.
6. This will open a new window File Upload.
7. Once you have located the file to upload click the Open button. This window will close.
8. You are now back in the Manage Attachments - Excel Forum window.
9. Click the Upload button and wait until the file has uploaded.
10. Close the window and then click Submit.

14. ## Re: Run Type error 13 Type Mismatch

The file is failing to sent for some reason. I might be too big (4MB?)

15. ## Re: Run Type error 13 Type Mismatch

Can I email you the file and then maybe you can share it with the members of the forum as there might be a problem with the file transfer mechanism.

16. ## Re: Run Type error 13 Type Mismatch

Can you not create a cut down version and attach that?

There are currently 1 users browsing this thread. (0 members and 1 guests)

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1