+ Reply to Thread
Results 1 to 14 of 14

Adding additional range to code

  1. #1
    Forum Contributor
    Join Date
    01-05-2010
    Location
    New York
    MS-Off Ver
    Excel 2016
    Posts
    747

    Adding additional range to code

    The following code copies data from the range A6:A7 on one sheet to the range B5:B6 on another sheet. I would like to change the code to paste to the range B5:B6 & E5:E6. How can I do this?

    Please Login or Register  to view this content.
    Last edited by rhudgins; 11-01-2010 at 07:49 PM.

  2. #2
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Adding additional range to code

    Repeat this line:
    Please Login or Register  to view this content.
    but change the first range address.
    Remember what the dormouse said
    Feed your head

  3. #3
    Forum Contributor
    Join Date
    01-05-2010
    Location
    New York
    MS-Off Ver
    Excel 2016
    Posts
    747

    Re: Adding additional range to code

    Thanks. My code is going to perform that same routine on sheets 20,21,22 & 23. How can I change my code to then run the macro RunResults on sheets 20,21,22 & 23 in numeric order?

    Please Login or Register  to view this content.

  4. #4
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Adding additional range to code

    You'd need a loop. Assuming that the macro runs on whatever sheet is active, you would need something like:
    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    01-05-2010
    Location
    New York
    MS-Off Ver
    Excel 2016
    Posts
    747

    Re: Adding additional range to code

    Thanks the only problem I am having with that solution is that the macro RunResults takes about 15 seconds to complete. After including the loop, the code is not waiting for RunResults to complete before heading to the next step.

  6. #6
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Adding additional range to code

    What does RunResults do?

  7. #7
    Forum Contributor
    Join Date
    01-05-2010
    Location
    New York
    MS-Off Ver
    Excel 2016
    Posts
    747

    Re: Adding additional range to code

    It is a long code that filters and copies data based upon multiple conditions.

  8. #8
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Adding additional range to code

    The code should not run asynchronously, so I was assuming you were doing some sort of background querying. If you are just filtering, there should not be that issue - assuming you are using the same instance of Excel to do the processing.

  9. #9
    Forum Expert
    Join Date
    01-03-2006
    Location
    Waikato, New Zealand
    MS-Off Ver
    2010 @ work & 2007 @ home
    Posts
    2,243

    Re: Adding additional range to code

    hi all,

    Snb & RomperStomper,
    Just to let you know that I think you are both working towards very similar goals - see the respective links for the flip side of the coin... http://www.excelforum.com/excel-prog...e-to-code.html & http://www.excelforum.com/excel-prog...ry-slowly.html

    Rhudgins,
    I think your various threads are so inter-related that they should all be in one place. Especially considering my below post which relates exactly to your question in this separate thread (http://www.excelforum.com/excel-prog...e-to-code.html).
    Quote Originally Posted by broro183 View Post
    Rhudgins,
    What does the "RunResults" macro do?
    To use someone else's words...
    Application.Run is synchronous. The call to Application.Run("Macro_1") will not return until the macro has finished executing. That said, if the macro starts an asynchronous process, then you might get the effect you describe. What do the macros do, and what evidence do you have that the macros are running in parallel? – Gary McGill Nov 9 '09 at 20:44
    Romper, should/can these threads be merged?
    Or is this linkage enough/too much ?
    (I've posted the same response in each of the threads.)

    Rob
    Rob Brockett
    Kiwi in the UK
    Always learning & the best way to learn is to experience...

  10. #10
    Forum Contributor
    Join Date
    01-05-2010
    Location
    New York
    MS-Off Ver
    Excel 2016
    Posts
    747

    Re: Adding additional range to code

    I am somewhat confused with what you just said.

    The destination ranges on sheet 20 should be filled with the values from A6:A7, then RunResults should run and then the same process should occur or sheets 21,22,23.

    RunResults should run independantly on the same worksheet as each destination range

  11. #11
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Adding additional range to code

    Rob,
    I'm going to leave the threads separate (for the time being, anyway) as the original purpose of this question is different.

  12. #12
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Adding additional range to code

    Quote Originally Posted by rhudgins View Post
    I am somewhat confused with what you just said.

    The destination ranges on sheet 20 should be filled with the values from A6:A7, then RunResults should run and then the same process should occur or sheets 21,22,23.

    RunResults should run independantly on the same worksheet as each destination range
    That's what should be happening. What specifically makes you think it isn't? (note: I am assuming that RunResults simply runs on the active sheet, not a specified sheet.)

  13. #13
    Forum Contributor
    Join Date
    01-05-2010
    Location
    New York
    MS-Off Ver
    Excel 2016
    Posts
    747

    Re: Adding additional range to code

    I apologize, it works fine. Thank you for the help!

  14. #14
    Forum Expert
    Join Date
    01-03-2006
    Location
    Waikato, New Zealand
    MS-Off Ver
    2010 @ work & 2007 @ home
    Posts
    2,243

    Re: Adding additional range to code

    Thanks RomperStomper,

    I'm not sure if "I've posted the same response in each of the threads" or not - my connection seems to have a very bad case of hic-cups tonight, so I apologise if I've made any duplicate posts...

    Ahhh well, it's Solved now, so it's all good :-)

    Rob

+ 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