+ Reply to Thread
Results 1 to 8 of 8

Simplify macro, make it dynamic

  1. #1
    Registered User
    Join Date
    01-09-2013
    Location
    Singapore
    MS-Off Ver
    Excel 2007
    Posts
    25

    Simplify macro, make it dynamic

    Hi

    I have a table in the range A4:W40. I recorded a macro that enters a VLOOKUP formula into cells U4, V4 and W4 then fills them down to row 22. I need to change this macro because sometimes I need the macro to fill down to row, 30, sometimes to row 20. It all depends on the values contained in column A. The first few rows in column A will all contain the text 'SG', the rest will be 'AU'. I only need the macro to fill down where the value in column A is SG.

    The macro:

    Please Login or Register  to view this content.
    Also, I'm sure that this macro is probably a little convoluted and could be a little more elegant.

    If anyone can offer any help with this, I'd be very appreciative.

    Cheers!

  2. #2
    Forum Expert millz's Avatar
    Join Date
    08-14-2013
    Location
    Singapore
    MS-Off Ver
    Excel, Access 2016
    Posts
    1,694

    Re: Simplify macro, make it dynamic

    Try this:

    Please Login or Register  to view this content.
    多么想要告诉你 我好喜欢你

  3. #3
    Registered User
    Join Date
    01-09-2013
    Location
    Singapore
    MS-Off Ver
    Excel 2007
    Posts
    25

    Re: Simplify macro, make it dynamic

    Hi Millz

    Thanks very much for your help!

    The macro works almost perfectly but it fills down one row too far. For example, I've got SG entries down to row 22 but it fills down the formula to row 23. I tested it by changing around entries in column A and each time, it filled down one row too far. Do you know why this might be happening?

    Again, really appreciate your input.

    Cheers

  4. #4
    Forum Expert millz's Avatar
    Join Date
    08-14-2013
    Location
    Singapore
    MS-Off Ver
    Excel, Access 2016
    Posts
    1,694

    Re: Simplify macro, make it dynamic

    Sorry, change to this (add -1):
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    01-09-2013
    Location
    Singapore
    MS-Off Ver
    Excel 2007
    Posts
    25

    Re: Simplify macro, make it dynamic

    Works perfectly, Millz! Really appreciate it, mate. Thank you!

  6. #6
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,528

    Re: Simplify macro, make it dynamic

    Millz is way ahead of me but since I had it ready I thought I might as well give you another option (no looping).

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    01-09-2013
    Location
    Singapore
    MS-Off Ver
    Excel 2007
    Posts
    25

    Re: Simplify macro, make it dynamic

    Thanks Jolivanes! Both work really well.

  8. #8
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,528

    Re: Simplify macro, make it dynamic

    Good luck with either one

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. How to simplify this macro
    By aneshdas in forum Excel Programming / VBA / Macros
    Replies: 19
    Last Post: 01-14-2014, 01:11 AM
  2. Specific url/folder called up in Macro. How to make that url dynamic?
    By JPWRana in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 10-24-2013, 10:40 AM
  3. Replies: 2
    Last Post: 07-25-2013, 01:55 PM
  4. Simplify macro
    By iamasimpleman in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-29-2011, 07:01 AM
  5. Need to make this hardcoded macro dynamic.
    By nagerpop in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-29-2010, 02:12 AM

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