+ Reply to Thread
Results 1 to 12 of 12

Would arrays work better?

  1. #1
    Registered User
    Join Date
    07-02-2022
    Location
    Lancashire, England
    MS-Off Ver
    365
    Posts
    6

    Would arrays work better?

    Hello,

    I have written the following routine in VBA and I am looking for advice to speed this up, as it is taking a little time to run.

    I'm thinking that because I have given instructions on a line-by-line basis, it is taking longer to run. Would it be better to replace the indiviual lines with arrays?



    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by |Dean|; 07-30-2022 at 08:47 AM.

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,916

    Re: Would arrays work better?

    Administrative Note:

    Welcome to the forum.

    We would very much like to help you with your query, however you need to include code tags around your code.

    Please take a moment to add the tags. Posting code between [code]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/code] tags makes your code much easier to read and copy for testing, and it also maintains VBA formatting.

    Please see Forum Rule #2 about code tags and adjust accordingly. Click on Edit to open your post, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    (Note: this change is not optional. As you are new here, I have done it for you this time.)
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,821

    Re: Would arrays work better?

    It would be easier to help and test possible solutions if you could attach a copy of your file. Explain in detail what you want to do referring to specific cells, rows, columns and sheets using a few examples from your data (de-sensitized if necessary). See the yellow banner at the top of this page for instructions to attach a file. In this manner we can see if you are using formulae and why in some cases you copy/paste and in other cases you simply make one cell equal to another.
    You can say "THANK YOU" for help received by clicking the Star symbol at the bottom left of the helper's post.
    Practice makes perfect. I'm very far from perfect so I'm still practising.

  4. #4
    Registered User
    Join Date
    07-02-2022
    Location
    Lancashire, England
    MS-Off Ver
    365
    Posts
    6

    Re: Would arrays work better?

    Hello AliGW,

    Thank you for your response. As you can tell, although I've been reading posts, but this is my first time making one.

    Thank you for making the change, I know for next time now
    Last edited by |Dean|; 07-30-2022 at 08:56 AM.

  5. #5
    Registered User
    Join Date
    07-02-2022
    Location
    Lancashire, England
    MS-Off Ver
    365
    Posts
    6

    Re: Would arrays work better?

    Hello Mumps1,

    Thank you for the response, I have uploaded the Excel file
    Last edited by |Dean|; 07-30-2022 at 08:58 AM.

  6. #6
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,482

    Re: Would arrays work better?

    After you input your data, are you not just copying the last row and pasting it to the row beneath?

  7. #7
    Registered User
    Join Date
    07-02-2022
    Location
    Lancashire, England
    MS-Off Ver
    365
    Posts
    6

    Re: Would arrays work better?

    Hi davesexcel,

    I am either copying value or copying formulas & formatting.

    When I enter the data in the message box there can be lag between pressing OK, and the routing completing. I wondered, if the way that I wrote the routine was the source of this lag and whether improvements could be made.

    I acknowledge that there is probably a simple answer that it what it is, however I thought I would ask the question.

  8. #8
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,821

    Re: Would arrays work better?

    See if this makes a difference:
    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    07-02-2022
    Location
    Lancashire, England
    MS-Off Ver
    365
    Posts
    6

    Re: Would arrays work better?

    Hi Mumps1,

    Thank you for looking at this.
    Last edited by |Dean|; 07-30-2022 at 09:29 AM.

  10. #10
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,821

    Re: Would arrays work better?

    I have simply copied/pasted the range from A to T and then inserted GasReadDate and GasRead into columns B and C. The formulae adjust automatically to the new row.

  11. #11
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    2,224

    Re: Would arrays work better?

    I did the same thing, but in a different way.
    Please Login or Register  to view this content.
    Artik

  12. #12
    Registered User
    Join Date
    07-02-2022
    Location
    Lancashire, England
    MS-Off Ver
    365
    Posts
    6

    Re: Would arrays work better?

    Hi Artik,

    It appears that I have over complicated the routine, thank you

+ 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. AutoFilter a column on 3 criteria using Arrays does not work
    By ritesh.sharma25 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-13-2018, 08:46 AM
  2. [SOLVED] SUM data with multiple ranges and criteria, I don't think arrays will work
    By Joachim17 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-26-2015, 05:30 PM
  3. Declaring multiple multi-dimensional arrays (jagged arrays) - compile error?
    By dfribush in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-20-2013, 05:06 PM
  4. Still learning arrays, not sure how to work with a particular range input/edit
    By Orestees in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 10-29-2012, 04:16 PM
  5. Excel 2007 : issues getting vlookup arrays to work
    By dmknails in forum Excel General
    Replies: 4
    Last Post: 01-27-2012, 10:26 AM
  6. Control arrays and initialize does not work!
    By tasamy in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-13-2010, 10:41 AM
  7. Can't get INDIRECT to work in combination with arrays
    By coldmejl in forum Excel General
    Replies: 2
    Last Post: 06-04-2008, 06:36 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