+ Reply to Thread
Results 1 to 4 of 4

Making Simple Recorded Macro Generally Applicable

  1. #1
    Registered User
    Join Date
    04-22-2012
    Location
    Ontario, Canada
    MS-Off Ver
    Excel 2010
    Posts
    15

    Making Simple Recorded Macro Generally Applicable

    These are the first two steps in a multi-stage macro I've recorded to grab a block of data, remove problems such as merged cells and percentages, throw out data I don't want, and sort the remaining values in which I'm interested. It's useful, but since it reflects the conditions of its recording it only works with columns of 204 rows. (This is why 204 and numbers close to it occur a lot below). What would I have to do to make the 204 a variable that I would input at the beginning, so that I could manipulate columns of any size?

    I won't bore the helpful people on this board with the full macro, but if someone could demonstrate how to generalize my first two steps, I'll be able to apply the principles to the rest. Thanks very much.

    The code:

    Please Login or Register  to view this content.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,463

    Re: Making Simple Recorded Macro Generally Applicable

    Normally, you establish the last row and use that in subsequent statements:

    Please Login or Register  to view this content.

    I'm a little confused about the ActiveCell part of your code though. Can the code be initiated from anywhere in the sheet?

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    04-22-2012
    Location
    Ontario, Canada
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: Making Simple Recorded Macro Generally Applicable

    Thank you--that puts me on the right track.

    Quote Originally Posted by TMShucks View Post
    I'm a little confused about the ActiveCell part of your code though. Can the code be initiated from anywhere in the sheet?
    No, the top left cell of the block of data to be manipulated has to be the active one at the beginning for the whole thing to work--if I've understood your question correctly.

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,463

    Re: Making Simple Recorded Macro Generally Applicable

    You're welcome. Thanks for the rep.

+ 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