VBA application.Caller type

Cityroller

New Member
Joined
Oct 17, 2017
Messages
6
I am creating a spreadsheet in which I am able to click a control button to bring up a form to enter dates, amounts, etc. It was working. Then it stopped. I wish I knew exactly what I changed, but I started receiving the run-time 13, type mismatch error on the line that assigns application.caller to buttonPress. Application.caller brings up "Button 7," a string. I tried not declaring the variable buttonPress and received the same error.
Originally this worked. What am I missing? Thank you.
Code:
Public whichButton As Integer, dataCell As Integer
Dim rowCount As Integer
Dim buttonNumber As String, buttonPress As String

Private Sub CommandButton1_Click()

If TextBox1.Value = "" Or TextBox2.Value = "" Or TextBox3 = "" Then
If MsgBox("Incomplete entry.  Continue?", vbQuestion + vbYesNo) <> vbYes Then
Exit Sub
End If
End If

If TextBox1.Value > WorksheetFunction.EoMonth(e2, 0) Then
MsgBox ("Exceeds current month.")
Call resetForm
debitBox.Show
Exit Sub
End If

If Not IsNumeric(TextBox1) Or Not IsNumeric(TextBox2) Then
MsgBox ("Needs a number")
Call resetForm
debitBox.Show
Exit Sub
End If

If Len(TextBox3) > 11 Then
MsgBox ("Comment too long")
Call resetForm
debitBox.Show
Exit Sub
End If

buttonPress = Application.Caller
buttonNumber = Mid(buttonPress, 8, 2)
whichButton = CInt(buttonNumber)

Call enterData
Call resetForm
debitBox.Hide
End Sub
 
Last edited by a moderator:

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
13 means you are trying to use a string in a numeric field.
you cannot put "14" into a number variable/field, or date field.

im not sure what a Application.Caller returns.
 
Upvote 0
Thank you. Application.Caller returns a string, and the variable is formatted as a string. Because I want the number from the end of the string, I've isolated it in the three lines above "Call enterData." It worked. Then it stopped working.

Thanks for your answer.
 
Upvote 0

Forum statistics

Threads
1,223,246
Messages
6,170,988
Members
452,373
Latest member
TimReeks

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