Run a Macro when a User Changes a Specific Cell, Range, or Any Cell in Excel

Поділитися
Вставка
  • Опубліковано 9 вер 2019
  • MY FULL EXCEL VBA COURSE [35% Discount]: www.teachexcel.com/vba-course...
    200+ Video Tutorials - 200+ Downloadable Excel Reference Files - 50+ Hours of Content
    Excel File: www.teachexcel.com/excel-tuto...
    Excel Forum: www.teachexcel.com/talk/micro...
    Simple way to run Excel vba macros when a user makes a change within the worksheet - this tutorial covers three different scenarios: when the user changes a specific cell, when the user changes something within a range of cells, and when a user changes any cell within a worksheet.
    This is a step-by-step explanation that covers everything you need to know, including multiple methods for identifying the cell that was changed, how to abstract range references to make your code more efficient and easier to manage, and how to reference regular macros from the code that figures out if a macro should be run or not.
    I hope you find this tutorial helpful!
    TeachExcel.com

КОМЕНТАРІ • 77

  • @TeachExcel
    @TeachExcel  2 роки тому +1

    MY FULL EXCEL VBA COURSE (Beginner to Expert) [35% Discount]: www.teachexcel.com/vba-course-update.php?src=yt_pinned_comment_HsiwC9xg06c
    200+ Video Tutorials - 200+ Downloadable Excel Reference Files - 50+ Hours of Content

  • @millsiom
    @millsiom 4 роки тому +2

    copy it, paste it, forget it - such a good logic, used it so many times

  • @nishantbhargava2040
    @nishantbhargava2040 3 роки тому

    Oh. My. God. I spent an hour googling stuff before I found this amazing video. The beginning part of where to put the code is the key, and not found anywhere else. Thank you!

  • @jdklc
    @jdklc 3 роки тому

    This is great - I have looked at 20 different sites that all have different syntax - I have spun in circles trouble shooting a basic problem of the trigger not firing - I knew it was a simple issue - thanks !!!!

  • @vipulDJhaveri
    @vipulDJhaveri 3 роки тому

    Brilliantly explained - helped me for firing on filling of values in range to send email automatically with macro2-thanks a lot

  • @raulbader
    @raulbader 4 роки тому +5

    Thanks a lot! Now I'll finally be able to do what I was trying to achieve.

  • @MsThing81092
    @MsThing81092 4 роки тому

    Great video! It really helped me in solving the problems I was running into. Thank you!!

  • @davecks3042
    @davecks3042 3 роки тому +1

    Couldn't understand better. Amazingly explained. Thank you

  • @lmajiedmary
    @lmajiedmary Рік тому

    Excellent video!! Helped me understand a lot of things in one video!! Thank you!!

  • @unitedelectricfootballleag1224
    @unitedelectricfootballleag1224 3 роки тому

    SUPERB!
    Clearly explained and well taught...

  • @EithneDolan
    @EithneDolan 4 роки тому

    Excellent Tutorial. A huge help. Thank you

  • @Ashrafhaa1
    @Ashrafhaa1 3 роки тому

    Thank You
    I Really Appreciate your way of explanation the topic you are talking about
    Thank You Again, Have a Nice Time with Great Regards

  • @solarpoppop9398
    @solarpoppop9398 4 роки тому +1

    Excellent tutorial! Thanks!

  • @Pankaj-Verma-
    @Pankaj-Verma- 4 роки тому

    Thank you so much for your great help.

  • @stewiegriffin6388
    @stewiegriffin6388 3 роки тому

    You helped solve my problem! Many Thanks!

  • @pabloortega3275
    @pabloortega3275 3 роки тому

    excellent video, it helped me a lot!

  • @alexanderwilliams-baimashk3775
    @alexanderwilliams-baimashk3775 3 роки тому

    Great video thanks. I am using this to automate a report that inserts the now function when someone logs an issue. Since the now function isn't static the macro takes the columns where the timestamp is and pastes it to make it hardcoded. I am now trying to work out however how I can delete the query when it's been completed and not trigger the macro.

  • @michaelramsey7592
    @michaelramsey7592 3 роки тому +2

    Excellent John! Now, if I change multiple cells all within the Intersect Range by dragging down the cell above, how can the script be changed to acknowledge the changed cells and react accordingly? The current example you used only recognizes the cell used to drag down.

  • @saqlainshaikh9936
    @saqlainshaikh9936 4 роки тому

    You ara amazing bro

  • @EricaDyson
    @EricaDyson 4 роки тому

    Great. Mega useful!

  • @exclusivelynyc
    @exclusivelynyc 3 роки тому +1

    Excellent video. I think this is going to help me alot.

    • @TeachExcel
      @TeachExcel  3 роки тому +1

      Thank you! And I'm very glad to hear it :))

  • @nadermounir8228
    @nadermounir8228 3 роки тому +2

    Very well explained! In fact I was wondering how to run 2 worksheet change events in one Macro. I tried many times without success

    • @TeachExcel
      @TeachExcel  3 роки тому

      Thanks!! I'm really glad I could help :)

  • @ROUKWA_S
    @ROUKWA_S Рік тому

    Nice Video ! I appreciate that you've shared this useful clip with us .
    Can this method be applied in case of multiple ranges and execute corresponding subroutines ?
    If it was , Can you share such like method ?

  • @ijnmpi
    @ijnmpi 4 роки тому +1

    Thanks a lot! it helped a great deal :)

    • @TeachExcel
      @TeachExcel  4 роки тому

      I'm very glad to hear it :)

  • @wayneedmondson1065
    @wayneedmondson1065 4 роки тому +2

    Great! Is it "Thanks for the video = Something" or "Not thanks for the video = Nothing".. haha! For the single cell test, I thought that you could just use: If Target = Range("A1") Then.. But, after tinkering with your code, I discovered that leaving off the .Address from Target.Address and Range("A1").Address will produce some wonky results. Thanks for that bit of learning. Typically, I use the If Not Intersect method anyway, even for a single cell reference. For some time, it confused me, because I was thinking: "if (pause) not intersect() is nothing". Then I realized that it is: "if not (pause) intersect() is nothing". I hope that helps someone struggling with it. Once I put the mental pause in the right place, the code made total sense and I've never confused it since. Thanks for sharing your knowledge.. it helps me move forward a little bit each day. Thumbs up!

    • @TeachExcel
      @TeachExcel  4 роки тому +1

      Glad to help man! I honestly almost always use the intersect method too but I know that the other one is easier for a lot of people and a lot of people just want one cell - I used the intersect method in another tutorial and someone mentioned this simple way to check for a single cell, but yea, it's almost like Excel and VBA just want to make our lives more difficult than they really need to be hah. (and copy/paste really is king for so much code lol)

  • @antoniovelasquez4110
    @antoniovelasquez4110 Рік тому

    Excellent! How would you go about having this work for every nth cell in a column? Like every 5th starting at A1

  • @lorrainego9298
    @lorrainego9298 3 роки тому

    thank you!!! this was why the module i use does not run automatically. i thought there was an error in the coding of the module itself but there was no error whenever i manually run it. so it was either it exited the sub right away or something else. turns out it was just not called to run TT_TT

  • @davidebr90
    @davidebr90 2 роки тому

    Thanks !

  • @deldavis989
    @deldavis989 2 роки тому

    Hi this demo is exactly what I’m looking for (change within a range). This is the cheeky part. Is it possible to run a demo working with Google Sheets? Many thx Del

  • @johnstonekennedy2571
    @johnstonekennedy2571 4 роки тому +1

    marvelous

  • @TheJaebeomPark
    @TheJaebeomPark 7 місяців тому

    thanks a lot

  • @ahmadaltayeb1983
    @ahmadaltayeb1983 3 роки тому

    Thanks Sir

  • @mohamedshuaau7934
    @mohamedshuaau7934 Рік тому

    Thanks

  • @asylux1096
    @asylux1096 3 роки тому +1

    I'm a mac user. As soon as I hit (general) dropdown I get "Variable uses Automation type not supported in Visual Basic? I've read that I can code it in I typed what you wrote, but still no joy.

  • @mileshuang8489
    @mileshuang8489 4 роки тому

    Hello there, do you know at 14:00 in your video why your typing at A6 is filled in yellow Color automatically? Thanks a lot.

  • @seowjiaxian
    @seowjiaxian Рік тому

    The options on the left and right drop down Menu, are the options only there from latest excel versions ?

  • @SoNonWoo
    @SoNonWoo 3 роки тому

    Question:
    changes in column values does not work if the value in the cell is produced from an Index(Match). How can I make it check if the target.text has changed?

  • @MolDo57
    @MolDo57 6 місяців тому

    I'm familiar with this VBA in clasic excell. But recently I noticed Automate tab in excel and code editor is not the clasic one. To make things fun scripts are being saved in cloud. BUT, it looks this is totaly diferent then clasic VB as SUB is not suported and we deal with "function" amd main function as part of it. How these new type of functions can be trigered by focus change ?

  • @karthikeyannandhakumar368
    @karthikeyannandhakumar368 4 роки тому

    Need help, I have multiple sheets where each sheet has queries but its running when i do refresh all but i want each sheet should get refreshed only when i change the value/value from list.. how can be achieved using marco scripts or any other way.

  • @flordi8235
    @flordi8235 3 роки тому

    Hi, supposing that i insert the string "cp" on A1 cell, what should i do to automatically return on A1 the string "completed" ? Thanks

  • @einnairo
    @einnairo 4 роки тому

    New sub here. I hv 2 questions.
    1. Can i pass more parameters into this sub?
    2. For a user to keep copy and paste this sub is not ideal. Can this go into a module or xlam file that everyone can use?
    Thanks!

  • @AngelRivera-mc8zc
    @AngelRivera-mc8zc 2 роки тому

    I was hoping to find something where the target is an actual formula and it’ll run the macros if the value changes due to another cell being changed

  • @testing-go3040
    @testing-go3040 3 роки тому

    hello I have long sheet when i click button, it should navigate to particular area (scrll down to the bottom) , do we have exampe?

  • @mylesharper3412
    @mylesharper3412 Рік тому

    Is there a way to make it print the specific cell that is changed?

  • @prashantpatil3635
    @prashantpatil3635 4 роки тому

    Hi this was great video for beginner.
    I learned how to Run a Macro when a User Changes a Specific Cell, Range, or Any Cell in Excel in very simple way.
    Could you please also load video,
    How to write code to track all modification done on one spreadsheet(Sheet1) for specific range Range - 'Sheet1'!$A$94!$A$3:$K$117"
    And track all log(MOdification ) details in different tab in same excel sheet
    Date || Day || Modified by || User Name || Cell Value change from || cell value change to
    Thanks in Advance !!

    • @ajayrathod7777
      @ajayrathod7777 Рік тому

      Bro I want vba code if even a single cell is changed in entire workbook,it should trigger a mail from outlook , trigger should happen on saving workbook

  • @MAHIPOLITO
    @MAHIPOLITO Рік тому

    How can do the same with Worksheet calculate, because you method the user need to type , and this will trigger an action ...... but I would like to have this starting automatically

  • @adebabarinde1541
    @adebabarinde1541 3 роки тому

    Hi please how can I create a macro to activate at 8am and activate at 8.10am

  • @videoart1496
    @videoart1496 2 роки тому

    Please I a need a help how to do this one please ? " When text in cell A1="YES" (text) then value at B1=10, If text in cell A1="NO", the value at B1=0, If text in cell A1=0, then value at B1="ERROR"

  • @georgehatzimanolakis1904
    @georgehatzimanolakis1904 Рік тому

    I need help because I can't word my query properly and so I can't find an answer:
    to isolate my issue, we have 3 cells. cell A is my "h:mm:ss.000" , cell B is another person's "h:mm:ss.000", and cell C is "the difference of those times
    I'm using an IF() so that if my time is higher: do x, if it is lower, do y. The way I worded the function in order for it to work without requiring negative values was just to subtract A from B if true or B from A if false. So the result is the same regardless. Now, I want the colour of cell C to change colour depending on if the IF() was true or false.
    With this video, I was able to at least get the colour to change when I manually change A or B but I want a cell of my choice to change cell A and that change will change cell C. (cell A "my time" is based on an average of times, and when I see a colour on cell 3, I can refer to another cell that tells me how much change in time do I need to produce, or how much cushion am I growing)
    so I will try to demo one result and if my average time changes and it changes the IF() from false to true, cell c=time->in green
    A b c > c
    1 my ave time a different time difference > show difference in time when false ->red font
    2 >
    3 >
    My only theory is I have to make a macro that does something that sets of another macro.

    • @georgehatzimanolakis1904
      @georgehatzimanolakis1904 Рік тому

      I tried to do if range("cell A").formula = true then.... but it didn't do anything

  • @rasmusmagelund
    @rasmusmagelund 3 роки тому

    How to handle, Insert and delete Rows / Columns in the Range, so Worksheet_change doesn't not run

  • @sayishshirodkar9634
    @sayishshirodkar9634 4 роки тому +2

    Does this work when cell changes it value automatically by formula ?

    • @addynaidu6470
      @addynaidu6470 4 роки тому +1

      No it doesn't. Tried as i'm looking for the same solution

    • @BruceWayne-mf6xf
      @BruceWayne-mf6xf 4 роки тому

      @@addynaidu6470 please share the link if you find a solution for this....

    • @addynaidu6470
      @addynaidu6470 4 роки тому

      @@BruceWayne-mf6xf hope this helps
      ua-cam.com/video/EndyCGyMw0Y/v-deo.html

  • @veeralshah4396
    @veeralshah4396 3 роки тому

    Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Intersect(Target, Range("A:A")) Is Nothing Then
    ActiveCell.Offset(-1, 0).Activate
    a = Sheets("Sheet2").Cells(Rows.Count, ("A")).End(xlUp).Row + 1
    Sheets("Sheet2").Range("A" & a).Value = ActiveCell.Value
    ActiveCell.Offset(1, 0).Select
    End If
    End Sub
    sir i am using above vba code to auto update in new sheet 2.
    My data is dynamically updated therefore it is not updating in new sheet 2
    if i enter data manually press enter it is updated but excel linking is not updated how to do that.

  • @harpreetsinghgrover
    @harpreetsinghgrover 2 роки тому

    how do i print Hi there in a cell instead of getting it as pop up, someone pls reply

  • @tanujsharma2812
    @tanujsharma2812 3 роки тому

    Okay , this calls the macro only after pressing the enter key , but my data changes automatically , and then it's not calling the macro

  • @zakbergmann7650
    @zakbergmann7650 3 роки тому

    is there a way to run a macro each time a slicer is used?

    • @TeachExcel
      @TeachExcel  3 роки тому

      Try a PivotTable change event. Note that working with Slicers in vba is SLOW, so if you will do that, set the ManualUpdate property to True for all connected PivotTables before you change their slicer selections.

  • @sankarmondal89
    @sankarmondal89 Рік тому

    It doesn't work unless the cell selects manually.

  • @ckdixit1975
    @ckdixit1975 4 роки тому +1

    I just searching this from a long time such a huge helping code. Like Cell_LostFocus()

  • @farhanislam3707
    @farhanislam3707 4 роки тому

    PLZ MAKE VIDEO ON
    HOW TO ADD PICTURE IN USERFORM ??

    • @TeachExcel
      @TeachExcel  4 роки тому

      Just go ask this in our forum and you will get a MUCH faster response - it is not difficult to do. www.teachexcel.com/talk/microsoft-office?src=yt

  • @gototcm
    @gototcm 3 роки тому

    Excel VBA logic is absolutely baffling at times.

    • @TeachExcel
      @TeachExcel  3 роки тому

      Yes, totally agree! But, once you learn it, you will actually start defaulting to doing things there instead of using formulas in the worksheet because of how much easier it can make things - weird to think that programming code can be easier than making in-cell formulas lol. My new vba course (coming soon) will help clear-up a lot of the confusion as well ;)

  • @gregbernard7861
    @gregbernard7861 Рік тому

    Double negative explanation makes sense.

  • @cypheir
    @cypheir 2 роки тому +1

    God Blass You.