Thanks Thanks:  0
Likes Likes:  0
Results 1 to 4 of 4

Thread: Macro's for dummies

  1. #1
    New Member
    Join Date
    Mar 2002
    Location
    Kevin
    Posts
    4
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Can someone please help out a relative beginner to excel. I would like to make a macro run automatically based on the value of a particular cell on the page. For example, if cell a1=1, then I want my macro named macro1 to run automatically. I am trying to tie this into a date. Can you please help and keep it in simple terms because like I said I am not an expert. Thank you in advance for any help.

  2. #2
    MrExcel MVP
    Join Date
    Feb 2002
    Location
    Sydney, Australia
    Posts
    2,940
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default

    Can someone please help out a relative beginner to excel. I would like to make a macro run automatically based on the value of a particular cell on the page. For example, if cell a1=1, then I want my macro named macro1 to run automatically. I am trying to tie this into a date. Can you please help and keep it in simple terms because like I said I am not an expert. Thank you in advance for any help.
    Hello,

    What you need to do is this:

    Right click your worksheet tab and choose View Code. This brings up the code sheet associated with that particular worksheet.

    You can program Excel to run macros when certain things happen e.g. a cell changing value. If the value in A1 is typed in then you could use this:-

    Code:
    Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Address = "$A" Then
        If Target.Value = 1 Then Macro1
    End If
    End Sub
    Where Macro1 would be in a standard module.

    If the value in A1 is based on a formula which might change because of a non-cell changing entry (e.g. NOW()) then you'd probably be best using the Worksheet_Calculate event:-

    Code:
    Private Sub Worksheet_Calculate()
    If Me.Range("A1") = 1 Then Macro1
    End Sub
    Hope that helps,
    D

  3. #3
    MrExcel MVP
    Join Date
    Feb 2002
    Location
    Sydney, Australia
    Posts
    2,940
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default

    The first procedure should be $A$1.

  4. #4
    Board Regular
    Join Date
    Feb 2002
    Posts
    99
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    On 2002-03-24 09:42, dk wrote:
    The first procedure should be $A$1.
    While you're in VBE, insert this script into another module:

    Sub macro1()
    MsgBox ("Hello world")
    End Sub

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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