Unable to Remove "Run Macro" in Developer

Denny57

Active Member
Joined
Nov 23, 2015
Messages
275
Office Version
  1. 365
Platform
  1. Windows
I hope someone can please help. I have created a file with a User Form and until I have finalised some additional code (I am doing this outside of the file) I have not applied macros to the command buttons on the worksheet.

However, I can normally open the User Form from the "Run" option in the Visual Basic tab on Developer. I have run some test entries but for some reason this option seems to be locked at "Run Macro". I had a message concerning a potential problem with the txtBMI record during the last "Add Record" but the calculation added the correct information.

I am hoping that someone can see the problem and help me to fix this apparent "freezing" of the program.

 
UPDATE:

It appears that this is happening to all my Excel files. I will try to find the generic solution, however if anyone has any ideas I would be grateful to receive them.
 
Upvote 0
Further Update
I am now receiving a Runtime Error 13 Type Mismatch message however the following code applies the correct calculation. The error appears at the line in BOLD.

VBA Code:
Private Sub txtWeight_AfterUpdate()
    txtWeight = Format(txtWeight, "#,##0.0")
    [B]txtBMI = (txtWeight.Value / (txtHeight.Value ^ 2))[/B]
    txtBMI = Format(txtBMI, "#,##0.0")
 
Upvote 0
After clearing txtWeight.Value = "" when txtWeight_AfterUpdate() is triggered, VBA tries to divide the void ("") by a number and this is a typical error.
VBA Code:
Private Sub txtWeight_AfterUpdate()

    If IsNumeric(txtWeight.Value) And Val(txtWeight.Value) > 0 Then
        txtBMI = (Val(txtWeight.Value) / (Val(txtHeight.Value) ^ 2))
        txtBMI = Format(txtBMI, "#,##0.0")
    Else
        txtBMI = ""
    End If

End Sub
 
Upvote 0
Solution
After clearing txtWeight.Value = "" when txtWeight_AfterUpdate() is triggered, VBA tries to divide the void ("") by a number and this is a typical error.
VBA Code:
Private Sub txtWeight_AfterUpdate()

    If IsNumeric(txtWeight.Value) And Val(txtWeight.Value) > 0 Then
        txtBMI = (Val(txtWeight.Value) / (Val(txtHeight.Value) ^ 2))
        txtBMI = Format(txtBMI, "#,##0.0")
    Else
        txtBMI = ""
    End If

End Sub
This work perfectly, thank you very much
 
Upvote 0
The error appears at the line in BOLD.
Hint for the future: If you want to apply your own format (eg bold, colour etc) to vba code in the forum, use the RICH tags not the VBA tags.

1743937558158.png


Rich (BB code):
Private Sub txtWeight_AfterUpdate()
    txtWeight = Format(txtWeight, "#,##0.0")
    txtBMI = (txtWeight.Value / (txtHeight.Value ^ 2))
    txtBMI = Format(txtBMI, "#,##0.0")
 
Upvote 0

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