+ Reply to Thread
Results 1 to 7 of 7

Auto call macro without pressing button

  1. #1
    Forum Contributor
    Join Date
    05-12-2012
    Location
    India, Chennai
    MS-Off Ver
    Excel 2003
    Posts
    182

    Auto call macro without pressing button

    Dear Experts

    Please help!!!

    I need to auto call macro without pressing button.
    example If user enters time in cell range("M4:M200")
    P4:P200 (=IF(M4="","",1)
    If P4:P200 "1" Call add_timepunch (macro)

    I have this below code
    Please Login or Register  to view this content.
    Last edited by skhari; 06-17-2015 at 12:44 PM. Reason: Code tag added

  2. #2
    Forum Guru karedog's Avatar
    Join Date
    10-03-2014
    Location
    Indonesia
    MS-Off Ver
    2003
    Posts
    2,971

    Re: Auto call macro without pressing button

    Hi,

    You forget to put your code inside code tag, please do so.

    Sub Worksheet_Change(ByVal Target As Range) is only triggered if changes is performed by hand (by manually typing in the target range), it will not triggered if the changes is caused by macro or as return value of function in target cell.

    So, you put formula in P4:P200 : =IF(M4="","",1), and when you type something in column M, the value in P4:P200 is also changed, but the changes is not by manual typing in P4:P200, but as a result of the function, that's why the Worksheet_Change() event is not triggered.

    The remedy for the situation is, instead tracking of P4:P200, you should use M4:M200 instead (the range that its value is changed by manually typing) :

    Please Login or Register  to view this content.

    Regards
    1. I care dog
    2. I am a loop maniac
    3. Forum rules link : Click here
    3.33. Don't forget to mark the thread as solved, this is important

  3. #3
    Registered User
    Join Date
    10-18-2012
    Location
    Amsterdam
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: Auto call macro without pressing button

    Can you be a bit more specific about your problem, is it only application.intersect that is not working? Or is the intersect working, but the procedure call add_timepunch is not?

  4. #4
    Forum Contributor
    Join Date
    05-12-2012
    Location
    India, Chennai
    MS-Off Ver
    Excel 2003
    Posts
    182

    Re: Auto call macro without pressing button

    @fotis
    Sorry for not posting inside code tag.
    @karedog
    I'm running clear function so I don't want manual entry
    Moreover I need it on only cell range (p4:p200) on calculation part.
    @sphspholz

    Procedure add_tumepunch is working fine
    Only issue with intersect

    Thank you for helping

  5. #5
    Forum Contributor
    Join Date
    05-12-2012
    Location
    India, Chennai
    MS-Off Ver
    Excel 2003
    Posts
    182

    Re: Auto call macro without pressing button

    @fotis
    Sorry for not posting inside code tag.
    @karedog
    I'm running clear function so I don't want manual entry
    Moreover I need it on only cell range (p4:p200) on calculation part.
    @sphspholz

    Procedure add_tumepunch is working fine
    Only issue with intersect

    Thank you for helping

  6. #6
    Forum Contributor
    Join Date
    05-12-2012
    Location
    India, Chennai
    MS-Off Ver
    Excel 2003
    Posts
    182

    Re: Auto call macro without pressing button

    I added code tag
    Thanks for your response

  7. #7
    Forum Guru karedog's Avatar
    Join Date
    10-03-2014
    Location
    Indonesia
    MS-Off Ver
    2003
    Posts
    2,971

    Re: Auto call macro without pressing button

    Yes, I know that you want to track any cell changes on range P4:P200, but as I said earlier that if the changes is performed by function of this range (the return value of function is changed), then the Worksheet_Change() event is not triggered.
    Have you tried the code that I provided in #2 ? Does it work ? If not, please tell in what behaviour it doesn't work, so I can amend the code.


    Regards

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. show area when pressing macro button
    By ossa in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-28-2012, 09:19 AM
  2. Macro to create form by pressing button
    By nani_nisha06 in forum Access Programming / VBA / Macros
    Replies: 0
    Last Post: 06-04-2012, 02:55 PM
  3. [SOLVED] Macro to create form by pressing button
    By jesika in forum Access Programming / VBA / Macros
    Replies: 3
    Last Post: 06-04-2012, 02:35 PM
  4. Command button auto select after pressing Enter
    By Bafa in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-21-2006, 03:05 AM
  5. Pressing a button using a macro
    By Todd in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-06-2005, 04:05 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1