I have an issue with the InputBox. my macro was working well. and this is my code so i find on google that if the CInt function is supplied with a text string that cannot be converted into a numeric value, it will return the error, is it true? or any advise?
Private Sub btn_check_Click()
Application.ScreenUpdating = False
Dim a, b, x, y, z, c As Long
Dim indicator, puzzlePartner, puzzleRaw As String
a = 5
b = 2
c = 5
Do Until Cells(c, 1) = ""
Sheet9.Cells(c, 3).Select
Sheet9.Cells(c, 56) = Trim(CStr(Left(Sheet9.Cells(c, 3), 15)))
c = c + 1
Loop
a = 5
Do Until Sheet9.Cells(a, 1) = ""
Do Until Sheet4.Cells(b, 104) = ""
If a = 2000 Then
c = 1
End If
If Sheet4.Cells(b, 9) = Sheet9.Cells(a, 9) And Sheet4.Cells(b, 27) = Sheet9.Cells(a, 27) And Sheet4.Cells(b, 26) = Sheet9.Cells(a, 26) And _
Sheet4.Cells(b, 25) = Sheet9.Cells(a, 25) And Sheet4.Cells(b, 24) = Sheet9.Cells(a, 24) And Sheet9.Cells(a, 52) = Sheet4.Cells(b, 104) And _
LCase(Trim(Sheet4.Cells(b, 21))) = LCase(Trim(Sheet9.Cells(a, 21))) Then
Sheet9.Cells(a, 53) = "True"
GoTo 1
ElseIf CInt(Cells(2, 3)) <> Year(Sheet9.Cells(a, 9)) And Sheet9.Cells(a, 15) = "Withdrawn" Then
Sheet9.Cells(a, 53) = "True"
GoTo 1
ElseIf CInt(Cells(2, 3)) <> Year(Sheet9.Cells(a, 9)) And Sheet9.Cells(a, 15) = "DC" Then
Sheet9.Cells(a, 53) = "True"
GoTo 1
ElseIf CInt(Cells(2, 3)) <> Year(Sheet9.Cells(a, 9)) And Sheet9.Cells(a, 15) = "PO" Then
Sheet9.Cells(a, 53) = "True"
GoTo 1
ElseIf Right(Sheet9.Cells(a, 7), 3) = "(S)" Then
Sheet9.Cells(a, 53) = "True"
GoTo 1
ElseIf CInt(Cells(2, 3)) <> Year(Sheet9.Cells(a, 51)) And Sheet9.Cells(a, 15) = "APP" Then
Sheet9.Cells(a, 53) = "True"
GoTo 1
ElseIf CInt(Cells(2, 3)) <> Year(Cells(a, 12)) And Right(Cells(a, 52), 3) = "RNW" Then
Sheet9.Cells(a, 53) = "True"
GoTo 1
End If
End If
2:
b = b + 1
Loop
Sheet9.Cells(a, 53) = "False"
x = CInt(Len(Sheet9.Cells(a, 52)))
y = x - 4
indicator = Mid(Sheet9.Cells(a, 52), y, 1)
If Sheet9.Cells(a, 53) = "False" And indicator = "-" Then
Sheet9.Cells(a, 53) = "Top-up"
End If
1:
b = 2
a = a + 1
Loop
I have also noticed that this error is shown on the line
ElseIf CInt(Cells(2, 3)) <> Year(Sheet9.Cells(a, 51)) And Sheet9.Cells(a, 15) = "APP" Then
Anyone have idea why is this happening?
Dim a, b, x, y, z, c As Longdoesn't do what you think it does.cis defined as a long, but all the other ones are defined asVariant- That is not a shortcut to Dimming variables of the same type.And the same goes forDim indicator, puzzlePartner, puzzleRaw As StringGoTo- it creates a mess out of your code. Use simple logic structures instead.<> Year(Sheet9.Cells(a, 51))because input year was blank. thats why show type mismatch<> Year(Sheet9.Cells(a, 51))because reflect value " " in input file, I dont fill the value, and how to add statement elseif if number <> blank value? any advise sir/madam?