VBA script or something else to automatically puch button

Ruben Schmitz

New Member
Joined
Aug 31, 2020
Messages
12
Office Version
  1. 365
Platform
  1. Windows
Hi,

Is it possible to make a VBA script or something else that automatically pushes a button with a macro in it?

for example, if the cell (1:I) has WAAR in it, that the button (planning maken) is pushed automatically (see image)?

It doesn't have to be this way, if you know something else it's fine too.

Thanks a lot,

Ruben Schmitz
 

Attachments

  • excel form 2.PNG
    excel form 2.PNG
    70.9 KB · Views: 5

Some videos you may like

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce

onlyadrafter

Well-known Member
Joined
Aug 19, 2003
Messages
5,703
Platform
  1. Windows
Hello,

try this code in the relevant sheet code window

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Address = "$I$1" And Target.Value = "WAAR" Then
        Application.Run ("YOUR MACRO NAME")
    End If
End Sub

change YOUR MACRO NAME to your planning maken macro name
 

Ruben Schmitz

New Member
Joined
Aug 31, 2020
Messages
12
Office Version
  1. 365
Platform
  1. Windows

ADVERTISEMENT

Hi,

I tried the code, but keep getting errors (see the image).

I tried a couple of things but nothing works.

do you know how I can make it work?

RS
 

Attachments

  • 1599120977751.png
    1599120977751.png
    200.4 KB · Views: 2

Ruben Schmitz

New Member
Joined
Aug 31, 2020
Messages
12
Office Version
  1. 365
Platform
  1. Windows
When I try taking this line out the first Sub-line VBA
Hello,

try this code in the relevant sheet code window

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Address = "$I$1" And Target.Value = "WAAR" Then
        Application.Run ("YOUR MACRO NAME")
    End If
End Sub

change YOUR MACRO NAME to your planning maken macro name

requires me to create a new macro when I try and run it, which then adds that line back in, and I am back to square one.
 

onlyadrafter

Well-known Member
Joined
Aug 19, 2003
Messages
5,703
Platform
  1. Windows

ADVERTISEMENT

Hello,

the code doesn't go into a standard module, you need to put it into one of the 'Blad' under Microsoft Excel Objects. The sheet where the WAAR is.

Your own code for the Planning Maken button should be in the Sub Planning_Maken()

Also the Application.Run ("Planning Maken") . should be Application.Run ("Planning_Maken"). It needs to call your already created macro for that button.
 

Ruben Schmitz

New Member
Joined
Aug 31, 2020
Messages
12
Office Version
  1. 365
Platform
  1. Windows
Hello,

the code doesn't go into a standard module, you need to put it into one of the 'Blad' under Microsoft Excel Objects. The sheet where the WAAR is.

Your own code for the Planning Maken button should be in the Sub Planning_Maken()

Also the Application.Run ("Planning Maken") . should be Application.Run ("Planning_Maken"). It needs to call your already created macro for that button.

Hi,

When I put the code in the sheet and start running the code it asked me to select a macro. Then I click on me macro Planning_maken en start running te macro. then the macro starts running for one time. But it isn't running automatically. When I delete the TRUE ( WAAR is the dutch word for TRUE) and type TRUE in (I;1) nothing happens.

In the second picture, you can see the Marco Planning_maken
 

Attachments

  • excel form3.PNG
    excel form3.PNG
    208.9 KB · Views: 1
  • excel form4 .PNG
    excel form4 .PNG
    141.9 KB · Views: 1

Ruben Schmitz

New Member
Joined
Aug 31, 2020
Messages
12
Office Version
  1. 365
Platform
  1. Windows
Hi,

When I put the code in the sheet and start running the code it asked me to select a macro. Then I click on me macro Planning_maken en start running te macro. then the macro starts running for one time. But it isn't running automatically. When I delete the TRUE ( WAAR is the dutch word for TRUE) and type TRUE in (I;1) nothing happens.

In the second picture, you can see the Marco Planning_maken

the Button is form control and not an Active x control
 

Watch MrExcel Video

Forum statistics

Threads
1,122,575
Messages
5,596,961
Members
414,114
Latest member
Lost_User21

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
Top