2

I'm trying to adopt the solution from this post & I've modified the macro slightly (I only need to add on button click) so that it's now

Sub AdjustValue()
    Dim btnName As String
    Dim targetCell As String
    Dim addAmount As Integer

    btnName = Application.Caller
    targetCell = Mid(btnName, 5, Len(btnName))
    addAmount = 1

    ActiveSheet.Range(targetCell).Value = ActiveSheet.Range(targetCell).Value + addAmount
End Sub

when I click my button, named 'Add_B3' it causes an error

The Macro May Not Be Available In This Workbook Or All Macros May Be Disabled

I've saved the macro to both the sheet that I'm working in & ThisWorkbook.

macro locations

I have set my Macro Settings in the Trust Center to 'Disable all macros with notification' but even if I select 'Enable all macros' I still hit the error and I can't work out why?

3
  • Try reassigning the button to the macro. – bdr9 Feb 11 '16 at 18:24
  • 1
    @bdr9 thanks, that was it. I just had to right click the button > Assign Macro > double click the macro name. Is there anywhere that I could have gone to check that the macro was assigned to the button? – Alex S Feb 11 '16 at 20:28
  • 1
    When you first right click on the button and choose Assign Macro, if you look at the "Macro name" text box, it should show you what macro is currently assigned to the button. – bdr9 Feb 11 '16 at 21:19
4

It looks like the button became unassigned from the macro. Try reassigning the button to the macro.

When you first right click on the button and choose Assign Macro, if you look at the "Macro name" text box, it should show you what macro is currently assigned to the button.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.