I need to make buttons to edit my formulas.

Goreful

New Member
Joined
Sep 3, 2014
Messages
2
Can somebody please help me with a formula for buttons? I need that when I press a button the formula changes or adds a spacific number. for example if formula is "=60*D45+O43"
I need to make buttons to make the number 60 to change to another number that i specified for that button. and if i have two buttons active at the same time the "60" will turn into the number that both buttons are combined.
I'm using Microsoft office professional plus 2010
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Welcome to the Board!

Q1. Instead of putting 60 in the formula, can you reference another cell then have each button put the appropriate number in that cell (which will affect the formula value) when the button is pressed?
Q2. What do you mean by "two buttons active" since you can't click 2 buttons at once?
Q3. What cell is the formula in?
 
Upvote 0
1. All buttons will be used only for one cell, because that cell is also linked to other cells. if that's what you mean with your first question.
Unless there is another way
2. if the one button is '60' and another is '40', once both are active the the value of the cell will turn into '100'
3. Right now I have it on D46 but that I could edit that
 
Upvote 0
Name your 40 & 60 toggle buttons tgl_40 and tgl_60, the part of the name after the underscore will be used to calculate the value in the formula. When either button is clicked it will run the TallyToggle subroutine which will figure which buttons are pressed and update the formula in D46. All code should be placed in the codepage for the worksheet that holds the toggle buttons.

Code:
Option Explicit

Private Sub tgl_40_Click()
    TallyToggle
End Sub

Private Sub tgl_60_Click()
    TallyToggle
End Sub

Sub TallyToggle()
    Dim lTotal As Long
    Dim lX As Long
    Dim ccc
    
    For lX = 1 To ActiveSheet.OLEObjects.Count
        With ActiveSheet.OLEObjects(lX)
            Set ccc = ActiveSheet.OLEObjects(lX)
            If TypeName(.Object) = "ToggleButton" Then
                If .Object.Value = True Then
                    lTotal = lTotal + CLng(Mid(.Name, InStr(.Name, "_") + 1))
                End If
            End If
        End With
    Next
    Range("D46").FormulaR1C1 = "=" & lTotal & "*R[-1]C+R[-3]C[11]"
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,643
Messages
6,120,702
Members
448,980
Latest member
CarlosWin

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