How do you make VBA code run automatically?

Jyggalag

Active Member
Joined
Mar 8, 2021
Messages
445
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Hi all,

I am very new to coding in VBA and am trying to figure out how to make my code run automatically. I want to copy paste values from one cell to another, but nothing happens with my current code, any idea why?

1651732421703.png


Thank you!
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Hit F5 or hit play symbol (right under "Book1" in the image)
or assign into a button/shape in sheet
 
Upvote 0
Hit F5 or hit play symbol (right under "Book1" in the image)
or assign into a button/shape in sheet
okay thank you.

But this is the macro solution no?

Is there a way to make it run automatically, so A1 is always = the value of B1?
 
Upvote 0
okay thank you.

But this is the macro solution no?

Is there a way to make it run automatically, so A1 is always = the value of B1?
So for example if I change the current value "Assessment" to "TestABC" in cell B1, cell A1 will automatically immediately update its value to this as well.
 
Upvote 0
Put in in sheet1_change even, to trigger change in cell B1 (with manual input in cell B1, not via formula)
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Address = "$B$1" Then Range("A1").Value = Range("B1").Value
End Sub
BTW, why not put formula in sheet, cell A1:
= B1
???
 
Upvote 0

Forum statistics

Threads
1,223,884
Messages
6,175,177
Members
452,615
Latest member
bogeys2birdies

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