+ Reply to Thread
Results 1 to 3 of 3

can i condense my code?

  1. #1
    Registered User
    Join Date
    02-11-2006
    Posts
    35

    can i condense my code?

    Hi

    I've got some code that works, but its impacting on the size of the spreadsheet severely.

    I'm wondering i can do a loop which executes the same code but just increases the row column by 1.

    So for example ive got the following code:

    Please Login or Register  to view this content.
    I really need this code to loop increasing by one number on each of the rows, at the moment ive just done the below, but as this happens from rows 11 through to 83...as you can imagine its effecting the spreadsheet size. Any help would be much appreciated

    Please Login or Register  to view this content.
    Last edited by dominicb; 07-04-2008 at 10:00 AM.

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689
    Maybe like this:
    Please Login or Register  to view this content.
    However, I'd look at making other changes to make the formula less complicated.

  3. #3
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464
    Hi,

    You could set a simple loop variable to represent the row number, and use the variable in the loop - untested but something like
    Please Login or Register  to view this content.

    However I'd be inclined to hold that Vlookup formula in a master cell, say C1, and give it a name. Then have the macro just copy it and paste it to C11:C83 in one hit. So suppose the C1 cell is named "MyForm" use a single line of macro code something like:



    Please Login or Register  to view this content.
    The problem with your existing code is that you are jumping backwards and forwards between the Visual Basic Environment (VBE) and Excel itself. There is a large time overhead associated with this. Far Better to just do a single Copy in one hit. You should find this speeds up your code and is far tidier to administer.

    HTH

+ 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