+ Reply to Thread
Results 1 to 4 of 4

macro worked when rec'd but not when run

  1. #1
    Registered User
    Join Date
    03-14-2007
    Location
    Buckinghamshire, England
    MS-Off Ver
    Professional 2010 14.0.5128.5000
    Posts
    32

    Question macro worked when rec'd but not when run

    Hi, can you help please? I have recorded a macro and it did exactly what I required when it was recorded, yet when I run it again the results are not the same.

    I want to identify occurances of '77' in column M and when found set the contents of column K to 'emeropid'.

    What I recorded was :-
    select 1st row and turned on auto-filter.
    selected '77' from autofilter dropdown.
    selected the column K cell of the first result and changed it to 'emeropid'
    copied that cell to the other rows identified by the auto filter.

    When I stopped recording and turned off the autofilter the results were exactly as planned - any row with 77 in column M had 'emeropid' on column K.

    To test it I replaced the entire Column K with the original unchanged data and ran the Macro. It did not make any changes at all. I don't understand why not, or how I can achieve what I'm trying to.

    The macro I recorded looks like this.

    '
    Rows("1:1").Select
    Range("C1").Activate
    Selection.AutoFilter
    ActiveWindow.LargeScroll ToRight:=1
    Selection.AutoFilter Field:=13, Criteria1:="77"
    Range("K5").Select
    ActiveCell.FormulaR1C1 = "metpol.emeropid"
    Range("K5").Select
    Selection.FillDown
    ActiveWorkbook.Save
    End Sub

    Any help would be appreciated.
    Pete
    Last edited by Woolmep; 10-23-2009 at 08:10 AM. Reason: problem solved

  2. #2
    Forum Contributor vijay2482's Avatar
    Join Date
    03-03-2009
    Location
    Paris,France
    MS-Off Ver
    Excel 2003
    Posts
    263

    Re: macro worked when rec'd but not when run

    Hi,

    Please use code tags in your post.

    If I understood correct, here a macro that does your requirement.
    Please Login or Register  to view this content.
    Hope it helps.
    VIjay

    If you find any of the post useful to your question, please add to the contributor's reputation by clicking the blue scales icon in the blue bar of the post.

  3. #3
    Registered User
    Join Date
    03-14-2007
    Location
    Buckinghamshire, England
    MS-Off Ver
    Professional 2010 14.0.5128.5000
    Posts
    32

    Re: macro worked when rec'd but not when run

    Vijay,

    It worked a treat. Thank you so much. I really wish I understood VB it sure is a powerful tool in the right hands.

    Regards
    Pete

  4. #4
    Forum Contributor vijay2482's Avatar
    Join Date
    03-03-2009
    Location
    Paris,France
    MS-Off Ver
    Excel 2003
    Posts
    263

    Re: macro worked when rec'd but not when run

    Happy to be of some help.
    Mark you post SOLVED.
    Last edited by vijay2482; 10-23-2009 at 07:18 AM.

+ 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