aoxolom
04-28-2018, 03:20 AM
Hi All,
New to this forum and VBA. I am currently making a calculator and it was working fine for sometime but now I am receiving an error "Runtime error -2147417848 (80010108) method _range of object _worksheet failed". Where as the only command that is running is to display a number from a cell into the textbox.
Major portion of my work is completed and this thing is now causing a heck of a problem for me and I am really sick and tired of dealing with this. Any type of help will be appreciated.
Regards,
Aoxolom
Following is code attached:
Private Sub TextBox8_Change()
IF KeyAscii > Asc("9") Or KeyAscii < Asc("0") Then
If KeyAscii = Asc("-") Then
If InStr(1, Me.TextBox8.Text, "-") > 0 Or _
Me.TextBox8.SelStart > 0 Then KeyAscii = 0
ElseIf KeyAscii = Asc(".") Then
If InStr(1, Me.TextBox8.Text, ".") > 0 Then KeyAscii = 0
Else
KeyAscii = 0
End If
End If
If IsNumeric(Application.Sheets("Main Calculator").Range("D19").Value) = False Then '(cause of error)
TextBox8.Text = "INVALID"
Else
TextBox8.Value = Application.Sheets("Main Calculator").Range("D19").Value
TextBox8.Value = Round(TextBox8.Text, 3)
End If
End Sub
New to this forum and VBA. I am currently making a calculator and it was working fine for sometime but now I am receiving an error "Runtime error -2147417848 (80010108) method _range of object _worksheet failed". Where as the only command that is running is to display a number from a cell into the textbox.
Major portion of my work is completed and this thing is now causing a heck of a problem for me and I am really sick and tired of dealing with this. Any type of help will be appreciated.
Regards,
Aoxolom
Following is code attached:
Private Sub TextBox8_Change()
IF KeyAscii > Asc("9") Or KeyAscii < Asc("0") Then
If KeyAscii = Asc("-") Then
If InStr(1, Me.TextBox8.Text, "-") > 0 Or _
Me.TextBox8.SelStart > 0 Then KeyAscii = 0
ElseIf KeyAscii = Asc(".") Then
If InStr(1, Me.TextBox8.Text, ".") > 0 Then KeyAscii = 0
Else
KeyAscii = 0
End If
End If
If IsNumeric(Application.Sheets("Main Calculator").Range("D19").Value) = False Then '(cause of error)
TextBox8.Text = "INVALID"
Else
TextBox8.Value = Application.Sheets("Main Calculator").Range("D19").Value
TextBox8.Value = Round(TextBox8.Text, 3)
End If
End Sub