Run-time error '13': Type mismatch on large font line

Nlhicks

Board Regular
Joined
Jan 8, 2021
Messages
244
Office Version
  1. 365
Platform
  1. Windows
Sub DoXfmrMath1()

Dim wsUpdate As Worksheet
Dim i As Long
Dim wb As Workbook
Dim wbFacility As Workbook
'Dim wsUpdate As Worksheet

Const cstrPath As String = "C:\Users\nhicks\Documents\Ratings\Saved Versions\"
Const cstrWbFacility As String = "WAPA-UGPR Facility Rating and SOL Record (Master).xlsm"
Const cstrwsUpdate As String = "Xfmr Update"

For Each wb In Workbooks
If LCase(wb.Name) = LCase(cstrWbFacility) Then
Set wbFacility = wb
Exit For
End If
Next wb
If wbFacility Is Nothing Then
If Dir(cstrWbFacility) <> "" Then
Set wbFacility = Workbooks.Open(cstrWbFacility)
Else
MsgBox "Could not find '" & cstrWbFacility & "' in current folder. Please open workbook and start again.", vbInformation, "Ending here"
GoTo end_here
End If
End If
If Evaluate("ISREF('[" & cstrWbFacility & "]" & cstrwsUpdate & "'!A1)") Then
Set wsUpdate = wbFacility.Sheets(cstrwsUpdate)
Else
MsgBox "Sheet '" & cstrUpdate & "' not found in workbook '" & cstrWbFacility, vbInformation, "Ending here"
GoTo end_here
End If
With wsUpdate
For i = 0 To 1
If .Cells(8 + (i * 4), "D").Value <> .Cells(8 + (i * 4), "E").Value Then
.Cells(11 + i, "P").Value = .Cells(8 + (i * 4), "E") - .Cells(8 + (i * 4), "D")
End If

If .Cells(10 + (i * 4), "D").Value <> .Cells(10 + (i * 4), "E").Value Then
.Cells(11 + i, "Q").Value = .Cells(10 + (i * 4), "E") - .Cells(10 + (i * 4), "D")
End If

If .Cells(16 + (i * 4), "D").Value <> .Cells(16 + (i * 4), "E").Value Then
.Cells(11 + i, "S").Value = .Cells(16 + (i * 4), "E") - .Cells(16 + (i * 4), "D")

End If
If .Cells(18 + (i * 4), "D").Value <> .Cells(18 + (i * 4), "E").Value Then
.Cells(11 + i, "T").Value = .Cells(18 + (i * 4), "E") - .Cells(18 + (i * 4), "D")
End If
Next i
' End If
End With
Call Xfmr_Bold_in_Concatenate1

end_here:
Set wsUpdate = Nothing

End Sub
 
Here is where the math gets done:
1670521864421.png
 
Upvote 0

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
If an exception can be written for this one case then the other cases work just fine.
 
Upvote 0
I still don't understand what you want to do in this case:
1670523717890.png

What result do you expect?

-----
Or in this case, what result do you expect?
1670523786476.png

-----

If in those cases you are not going to perform the subtraction, after declaring the variables then add this instruction in your macro:
VBA Code:
On Error Resume Next

In future please use code tags when posting code How to Post Your VBA Code it makes your code easier to read & copy, thereby increasing you chances of getting help.
 
Upvote 0
Well, What I would want is for the math to take 150-200 and give me -50 and then take 75-100 and give me -25 but write it like -50/-25 and paste it into the right box.

I am thinking about writing on error go to DoubleRating: then writing MsgBox "Please do these calculations by hand, they differ from the rest of the ratings and this code will not calculate them for you, sorry" but that is kind of taking the easy way out and I don't really want to do that.
 
Upvote 0
Here is a snapshot of the spreadsheet and you can see the one line hat differs from all of the rest. I will also run into an issue when I pull up lines that have --- in them but I am pretty sure I know how to deal with those since I had them on my last sheet. The 200/100 is a whole new issue that I didn't realize that I had until now.



1670524673669.png
 
Upvote 0
I can't help you that way.
  • You are not putting the information coherently.
  • At the beginning of your post you have an image, now you put another image.
  • In post #13, I give the example 200/100 and you respond with another example: 150-200. So I still don't understand what to do.
  • Your images are not complete, the rows and columns are not visible.
  • Use the XL2BB tool to put examples from your sheet.
 
Upvote 0
I cannot use XL2BB from my work computer and the information on the first image is being pulled from the second image. I simply provided the images to help you understand how the code is working. The only issue if figuring out how to do the math when the the spreadsheet in image two has 200/100 and the user wants to update that limit to 150/75 the code needs to do the math for the user such as (150-200/75-100) giving the result in the Delta Value of -50/-25 MVA
 
Upvote 0
Never mind, even when I try to make the math work in a basic excel worksheet, excel gets confused and instead of keeping the answers in its fractional form it solves it into a a numerical value. I will have to come up with a different solution.
 
Upvote 0

Forum statistics

Threads
1,215,214
Messages
6,123,659
Members
449,114
Latest member
aides

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top