+ Reply to Thread
Results 1 to 6 of 6

the macro don't execute

  1. #1
    robson soares
    Guest

    the macro don't execute

    I wrote a code of macros in the VBA and it does not execute automatically
    when I give a manual command to it execute, the macro functions normally but
    it never functions with the update of a cell of excel

  2. #2
    Don Guillett
    Guest

    Re: the macro don't execute

    It is ALWAYS useful to post your code here for comments. Do NOT attach a
    workbook.
    Maybe calculation is set to manual?

    --
    Don Guillett
    SalesAid Software
    [email protected]
    "robson soares" <robson [email protected]> wrote in message
    news:[email protected]...
    >I wrote a code of macros in the VBA and it does not execute automatically
    > when I give a manual command to it execute, the macro functions normally
    > but
    > it never functions with the update of a cell of excel




  3. #3
    Bob Phillips
    Guest

    Re: the macro don't execute

    Perhaps you haven't c reated it in such a way that it automatically
    executes. Show the code, and tell us EXACTLY where you stored it.

    --
    HTH

    Bob Phillips

    (remove nothere from email address if mailing direct)

    "robson soares" <robson [email protected]> wrote in message
    news:[email protected]...
    > I wrote a code of macros in the VBA and it does not execute automatically
    > when I give a manual command to it execute, the macro functions normally

    but
    > it never functions with the update of a cell of excel




  4. #4
    Tom Ogilvy
    Guest

    Re: the macro don't execute

    http://www.cpearson.com/excel/events.htm
    for an overview of events at Chip Pearson's site.

    Sounds like you want to use the Change event or the Calculate event.

    Private Sub Worksheet_Change(ByVal Target As Range)

    End Sub

    Private Sub Worksheet_Calculate()

    End Sub

    Properly structured and located, these can be useful with the situation you
    describe.

    --
    Regards,
    Tom Ogilvy

    "robson soares" <robson [email protected]> wrote in message
    news:[email protected]...
    > I wrote a code of macros in the VBA and it does not execute automatically
    > when I give a manual command to it execute, the macro functions normally

    but
    > it never functions with the update of a cell of excel




  5. #5
    robson soares
    Guest

    Re: the macro don't execute

    it follows below my macro:

    Private Sub Worksheet_Calculate()

    Dim col1
    Dim col2
    Dim col3
    Dim lin

    lin = 13
    col1 = 8
    col2 = 12
    col3 = 13


    For lin = 13 To 2057

    If Cells(lin, col1) = 1 And Cells(lin, col3) = 0 Then
    Cells(lin, col3) = 1
    Cells(lin, col2) = Now()
    End If

    If Cells(lin, col1) = 0 Then
    Cells(lin, col3) = 0
    Cells(lin, col2) = ""
    End If

    If Cells(lin, col1 + 1) = 1 And Cells(lin, col3 + 2) = 0 Then
    Cells(lin, col3 + 2) = 1
    Cells(lin, col2 + 2) = Now()
    End If

    If Cells(lin, col1 + 1) = 0 Then
    Cells(lin, col3 + 2) = 0
    Cells(lin, col2 + 2) = ""
    End If

    If Cells(lin, col1) = 1 And Cells(lin, col1 + 1) = 1 Then
    Cells(lin, 11) = Abs(Cells(lin, 14) - Cells(lin, 12))
    Else
    Cells(lin, 11) = ""
    End If

    Next

    End Sub





    "Tom Ogilvy" escreveu:

    > http://www.cpearson.com/excel/events.htm
    > for an overview of events at Chip Pearson's site.
    >
    > Sounds like you want to use the Change event or the Calculate event.
    >
    > Private Sub Worksheet_Change(ByVal Target As Range)
    >
    > End Sub
    >
    > Private Sub Worksheet_Calculate()
    >
    > End Sub
    >
    > Properly structured and located, these can be useful with the situation you
    > describe.
    >
    > --
    > Regards,
    > Tom Ogilvy
    >
    > "robson soares" <robson [email protected]> wrote in message
    > news:[email protected]...
    > > I wrote a code of macros in the VBA and it does not execute automatically
    > > when I give a manual command to it execute, the macro functions normally

    > but
    > > it never functions with the update of a cell of excel

    >
    >
    >


  6. #6
    Tom Ogilvy
    Guest

    Re: the macro don't execute

    Did you right click on the sheet tab and select view code, then place that
    code in the resulting module.

    Are Events Enabled?

    Run code like

    sub MakeitRun()
    Application.EnableEvents = True
    End sub

    Your code ran for me.

    --
    Regards,
    Tom Ogilvy


    "robson soares" <[email protected]> wrote in message
    news:[email protected]...
    > it follows below my macro:
    >
    > Private Sub Worksheet_Calculate()
    >
    > Dim col1
    > Dim col2
    > Dim col3
    > Dim lin
    >
    > lin = 13
    > col1 = 8
    > col2 = 12
    > col3 = 13
    >
    >
    > For lin = 13 To 2057
    >
    > If Cells(lin, col1) = 1 And Cells(lin, col3) = 0 Then
    > Cells(lin, col3) = 1
    > Cells(lin, col2) = Now()
    > End If
    >
    > If Cells(lin, col1) = 0 Then
    > Cells(lin, col3) = 0
    > Cells(lin, col2) = ""
    > End If
    >
    > If Cells(lin, col1 + 1) = 1 And Cells(lin, col3 + 2) = 0 Then
    > Cells(lin, col3 + 2) = 1
    > Cells(lin, col2 + 2) = Now()
    > End If
    >
    > If Cells(lin, col1 + 1) = 0 Then
    > Cells(lin, col3 + 2) = 0
    > Cells(lin, col2 + 2) = ""
    > End If
    >
    > If Cells(lin, col1) = 1 And Cells(lin, col1 + 1) = 1 Then
    > Cells(lin, 11) = Abs(Cells(lin, 14) - Cells(lin, 12))
    > Else
    > Cells(lin, 11) = ""
    > End If
    >
    > Next
    >
    > End Sub
    >
    >
    >
    >
    >
    > "Tom Ogilvy" escreveu:
    >
    > > http://www.cpearson.com/excel/events.htm
    > > for an overview of events at Chip Pearson's site.
    > >
    > > Sounds like you want to use the Change event or the Calculate event.
    > >
    > > Private Sub Worksheet_Change(ByVal Target As Range)
    > >
    > > End Sub
    > >
    > > Private Sub Worksheet_Calculate()
    > >
    > > End Sub
    > >
    > > Properly structured and located, these can be useful with the situation

    you
    > > describe.
    > >
    > > --
    > > Regards,
    > > Tom Ogilvy
    > >
    > > "robson soares" <robson [email protected]> wrote in

    message
    > > news:[email protected]...
    > > > I wrote a code of macros in the VBA and it does not execute

    automatically
    > > > when I give a manual command to it execute, the macro functions

    normally
    > > but
    > > > it never functions with the update of a cell of excel

    > >
    > >
    > >




+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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