• Delete macro button (2003)

    Author
    Topic
    #451120

    I have a macro that is executed from a button. At the end of the macro,I want to delete the button.

    How do I do this,I am unsure of the button’s properties (object)??

    Thanks

    Viewing 0 reply threads
    Author
    Replies
    • #1109826

      How did you create the button? From the Forms toolbar or from the Control Toolbox toolbar?

      • #1109827

        The button is from the forms toolbar

        • #1109828

          Try this instruction:

          ActiveSheet.Shapes(Application.Caller).Delete

          • #1109830

            Thankyou Hans.

            The sheet has 6 different buttons, is this specific to the button that called the procedure?

            May I also ask another question please.. (on a different subject)

            I have set my range to rg1. Within the range, I want to insert a formula only if:

            Column A = NON 6506 ITEMS

            And

            Column H = HBBA 99 6506

            I have

            rg1.Formula = “=value(mid(B2,11,5))”

            but need to build in the 2 conditions. How do I do that?

            • #1109831

              1) In this situation, Application.Caller returns the name of the specific button that called the macro.

              2) What do you mean by “Column A = NON 6506 ITEMS”? Should a specific cell in column A contain this value, or any cell, or…?

            • #1109834

              The range is variable.

              Eg: Sheet ‘rejections 2’ column M from row 2 until end of data (backwards).

              The formula should be input to the range (column M) if column A = NON 6506 ITEMS and column H = HBBA 99 6506

              Hope this makes sense, I have attached the code incase.

              Thanks

            • #1109835

              What exactly do you want?

              1) Only insert the formula in cells in column M where cells in the same row in columns A and H meet the criteria.

              – or –

              2) Insert a formula in all cells but make it return a blank if the cells in the same row in columns A and H meet the criteria.

              – or –

              3) Something else…?

            • #1109836

              Number 1 please Hans.

            • #1109837

              You’ll have to create a loop:

              Dim r1 As Long
              For r1 = 2 To q1
              If Range(“A” & r1) = “NON 6506 ITEMS” And Range(“H” & r1) = “HBBA 99 6506” Then
              Range(“M” & r1).Formula = “=Value(Mid(B” & r1 & “,11,5))”
              Else
              Range(“M” & r1).ClearContents
              End If
              Next r1

            • #1109849

              Hans,
              It worked a treat.
              Thanks thankyou

    Viewing 0 reply threads
    Reply To: Delete macro button (2003)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: