+ Reply to Thread
Results 1 to 8 of 8

Code optimization and Dynamic changing

  1. #1
    Registered User
    Join Date
    05-30-2013
    Location
    Sweden
    MS-Off Ver
    Excel 2010
    Posts
    68

    Code optimization and Dynamic changing

    Hi,

    I have two points I would like to ask your help with:

    1- I got help from some people in this forum to write a code that copy and transpose some rows (see the attached file), I have developed the code to fit my needs, however, since I have very poor skills in VBA I wonder if the code can be optimized i.e. written in a more efficient way.

    2-In the file (both sheets) there are 22 info fields (columns A to V). this might be changed in the future so that there might be more or less info fields. My question is how to make the code adjusts automatically to the numbers of columns before the "Option" columns? i.e. the code should look for the cell "Option1" regardless of its location and perform accordingly.

    Hope I could clarif ywhat I need.

    BR
    //Emma
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor
    Join Date
    09-21-2011
    Location
    Birmingham UK
    MS-Off Ver
    Excel 2003/7/10
    Posts
    2,188

    Re: Code optimization and Dynamic changing

    Set up another loop for this, for i =1 to 22

    Please Login or Register  to view this content.
    Hope this helps

    Sometimes its best to start at the beginning and learn VBA & Excel.

    Please dont ask me to do your work for you, I learnt from Reading books, Recording, F1 and Google and like having all of this knowledge in my head for the next time i wish to do it, or wish to tweak it.
    Available for remote consultancy work PM me

  3. #3
    Forum Expert Bob Phillips's Avatar
    Join Date
    09-03-2005
    Location
    Wessex
    MS-Off Ver
    Office 2003, 2010, 2013, 2016, 365
    Posts
    3,284

    Re: Code optimization and Dynamic changing

    Please Login or Register  to view this content.

  4. #4
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Code optimization and Dynamic changing

    Maybe:

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    05-30-2013
    Location
    Sweden
    MS-Off Ver
    Excel 2010
    Posts
    68

    Re: Code optimization and Dynamic changing

    Thank you John,
    the code looks much better, just two points still:
    1- in the input sheet the "Options" columns (W,X and Y) are not mandatory, so there might be an entry in a row without any entry in any of the options columns, in this case this row should be copied exactly as is into the output sheet, the code you provided does not copy the rows values from input sheet to output sheet unless they have a value in at least one value in the Options columns.
    2-The info headers in row1 in input sheet might have comments which I want them to be taken to the output sheet when the header row is copied there.

    BR
    //Emma

  6. #6
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Code optimization and Dynamic changing

    Maybe:

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    05-30-2013
    Location
    Sweden
    MS-Off Ver
    Excel 2010
    Posts
    68

    Re: Code optimization and Dynamic changing

    Great!

    that works, Thank you John.

    B Regards
    //Emma

  8. #8
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Code optimization and Dynamic changing

    You're welcome. Glad to help out and thanks for the feedback. Please mark this thread as solved.

+ 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. [SOLVED] Changing code from Static to Dynamic
    By JamesFletcher in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-29-2013, 04:33 AM
  2. [SOLVED] Changing static code to dynamic code
    By JamesFletcher in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-14-2013, 07:31 AM
  3. Code Optimization for Fun
    By Mordred in forum The Water Cooler
    Replies: 15
    Last Post: 07-23-2011, 12:47 PM
  4. Optimization VBA code
    By ahmad123 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-07-2011, 05:35 PM
  5. VBA optimization of code
    By Fazered in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-16-2007, 12:36 PM

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