Closed Thread
Results 1 to 4 of 4

Thread: Running Excel Macros Automatically IF...

  1. #1
    Registered User
    Join Date
    11-12-2011
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    2

    Running Excel Macros Automatically IF...

    Hi!

    I desperately need some help with some excel macros, can anybody help please?

    I need the VBA code so that an excel macros will run once automatically when, for example cell A4 = 1.

    Using a great thread posted by Zack Barresse, I've managed to get this far with the VBA:

    Sub copytohere()
    If ThisWorkbook.Sheets("Sheet1").Range("A4").Value = "1" Then
    Range("A1").Select
    Selection.Copy
    Range("E1").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False
    Range("A1").Select
    Application.CutCopyMode = False
    Selection.ClearContents
    End If
    End Sub

    I dont think I've got it quite right though...
    Can anyone help please? :-)

    This macros is basic - all it does is copy data from cell A1 to E1 and then deletes A1.
    I was hoping the IF statement would make the macros run once automatically when cell A4 = 1 however when I enter 1 into cell A4 nothing happens.

    What is interesting is that if i then go to run the macros manually, it will perform the macros correctly if cell A4 = 1 .If cell A4 doesn't equal 1 and I run the macros manually, nothing happens.

    I need the VBA so that the macros will run once automatically when cell A4 equals 1.

    Any help si much appreciated.

    Thank you! Thank you! Thank you! Thank you! Thank you! Thank you!!!


    Paddy

  2. #2
    Forum Guru TMShucks's Avatar
    Join Date
    07-15-2010
    Location
    Manchester, England
    MS-Off Ver
    MSO 2003 & 2007
    Posts
    6,230

    Re: Running Excel Macros Automatically IF...

    Hello and welcome to the forum. Please take a moment to read the forum rules.

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here

  3. #3
    Registered User
    Join Date
    02-01-2011
    Location
    California, USA
    MS-Off Ver
    Excel 2000
    Posts
    15

    Re: Running Excel Macros Automatically IF...


  4. #4
    Forum Guru TMShucks's Avatar
    Join Date
    07-15-2010
    Location
    Manchester, England
    MS-Off Ver
    MSO 2003 & 2007
    Posts
    6,230

    Re: Running Excel Macros Automatically IF...

    This is a duplicate post and as such does not comply with Rule 5 of our forum rules. This thread will now be closed, you may continue in your other thread.

    Thread Closed.

Closed Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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.2.0