Тёмный

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

TeachExcel
Подписаться 255 тыс.
Просмотров 145 тыс.
50% 1

MY FULL EXCEL VBA COURSE [35% Discount]: www.teachexcel...
200+ Video Tutorials - 200+ Downloadable Excel Reference Files - 50+ Hours of Content
Excel File: www.teachexcel...
Excel Forum: www.teachexcel...
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

Опубликовано:

 

2 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 78   
@TeachExcel
@TeachExcel 2 года назад
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
@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!
@wayneedmondson1065
@wayneedmondson1065 5 лет назад
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 5 лет назад
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)
@solarpoppop9398
@solarpoppop9398 4 года назад
Excellent tutorial! Thanks!
@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
@raulbader
@raulbader 4 года назад
Thanks a lot! Now I'll finally be able to do what I was trying to achieve.
@stewiegriffin6388
@stewiegriffin6388 3 года назад
You helped solve my problem! Many Thanks!
@MsThing81092
@MsThing81092 4 года назад
Great video! It really helped me in solving the problems I was running into. Thank you!!
@asylux1096
@asylux1096 3 года назад
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.
@MolDo57
@MolDo57 8 месяцев назад
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 ?
@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
@seowjiaxian
@seowjiaxian 2 года назад
The options on the left and right drop down Menu, are the options only there from latest excel versions ?
@pabloortega3275
@pabloortega3275 3 года назад
excellent video, it helped me a lot!
@davidebr90
@davidebr90 3 года назад
Thanks !
@antoniovelasquez4110
@antoniovelasquez4110 Год назад
Excellent! How would you go about having this work for every nth cell in a column? Like every 5th starting at A1
@jaimebruni6782
@jaimebruni6782 Месяц назад
Hello, I'm looking for a way to run a specific macro based on the content of a specific cell. Something like, if cell A2 = "text 1", run macro 1... if cell A2 = "text 2", run macro 2... I don't need to know when it changed, only to run the macros.. Do you have any tutorial how to do this? Thank you very much!
@michaelramsey7592
@michaelramsey7592 3 года назад
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.
@cypheir
@cypheir 2 года назад
God Blass You.
@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.
@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
@millsiom
@millsiom 4 года назад
copy it, paste it, forget it - such a good logic, used it so many times
@ckdixit1975
@ckdixit1975 4 года назад
I just searching this from a long time such a huge helping code. Like Cell_LostFocus()
@sankarmondal89
@sankarmondal89 Год назад
It doesn't work unless the cell selects manually.
@davecks3042
@davecks3042 3 года назад
Couldn't understand better. Amazingly explained. Thank you
@nadermounir8228
@nadermounir8228 4 года назад
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 4 года назад
Thanks!! I'm really glad I could help :)
@sayishshirodkar9634
@sayishshirodkar9634 4 года назад
Does this work when cell changes it value automatically by formula ?
@addynaidu6470
@addynaidu6470 4 года назад
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 ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-EndyCGyMw0Y.html
@harpreetsinghgrover
@harpreetsinghgrover 3 года назад
how do i print Hi there in a cell instead of getting it as pop up, someone pls reply
@mylesharper3412
@mylesharper3412 Год назад
Is there a way to make it print the specific cell that is changed?
@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"
@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.
@gregbernard7861
@gregbernard7861 Год назад
Double negative explanation makes sense.
@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
@TheJaebeomPark
@TheJaebeomPark 9 месяцев назад
thanks a lot
@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 ?
@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?
@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
@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?
@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
@einnairo
@einnairo 5 лет назад
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!
@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
@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
@exclusivelynyc
@exclusivelynyc 3 года назад
Excellent video. I think this is going to help me alot.
@TeachExcel
@TeachExcel 3 года назад
Thank you! And I'm very glad to hear it :))
@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.
@rasmusmagelund
@rasmusmagelund 3 года назад
How to handle, Insert and delete Rows / Columns in the Range, so Worksheet_change doesn't not run
@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
@lmajiedmary
@lmajiedmary 2 года назад
Excellent video!! Helped me understand a lot of things in one video!! Thank you!!
@johnstonekennedy2571
@johnstonekennedy2571 4 года назад
marvelous
@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.
@mohamedshuaau7934
@mohamedshuaau7934 Год назад
Thanks
@adebabarinde1541
@adebabarinde1541 3 года назад
Hi please how can I create a macro to activate at 8am and activate at 8.10am
@ijnmpi
@ijnmpi 4 года назад
Thanks a lot! it helped a great deal :)
@TeachExcel
@TeachExcel 4 года назад
I'm very glad to hear it :)
@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 !!!!
@unitedelectricfootballleag1224
@unitedelectricfootballleag1224 3 года назад
SUPERB! Clearly explained and well taught...
@Darshanam-Jatra
@Darshanam-Jatra 3 года назад
Brilliantly explained - helped me for firing on filling of values in range to send email automatically with macro2-thanks a lot
@ahmadaltayeb1983
@ahmadaltayeb1983 3 года назад
Thanks Sir
@EithneDolan
@EithneDolan 4 года назад
Excellent Tutorial. A huge help. Thank you
@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 ;)
@Pankaj-Verma-
@Pankaj-Verma- 4 года назад
Thank you so much for your great help.
@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.
@saqlainshaikh9936
@saqlainshaikh9936 4 года назад
You ara amazing bro
@EricaDyson
@EricaDyson 5 лет назад
Great. Mega useful!
@farhanislam3707
@farhanislam3707 5 лет назад
PLZ MAKE VIDEO ON HOW TO ADD PICTURE IN USERFORM ??
@TeachExcel
@TeachExcel 5 лет назад
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
Далее
Excel VBA: The Magic of the Worksheet Change Event
14:24
When Goalkeepers Get Bored 🤯 #3
00:27
Просмотров 1,7 млн
I Built a SECRET Lamborghini Dealership!
33:02
Просмотров 6 млн
Run Macros at Set Intervals in Excel
13:20
Просмотров 21 тыс.
Excel VBA - How to Run Macro when Cell Changes
4:12
Просмотров 130 тыс.
Excel VBA - How to Run Macro when Cell Changes
7:37
Просмотров 40 тыс.
Run Macro when Result of Formula Changes
3:46
Просмотров 16 тыс.
The Best Tips for Recording Macros in Excel
22:18
Просмотров 115 тыс.
VBA Macro to Copy Data from Another Workbook in Excel
13:39
Run Macro If Cell Value Changes / Excel VBA Tutorial
5:44
When Goalkeepers Get Bored 🤯 #3
00:27
Просмотров 1,7 млн