+ Reply to Thread
Results 1 to 13 of 13

Multiple Named Ranges Pasting Loop issue

  1. #1
    Registered User
    Join Date
    04-30-2010
    Location
    NYC
    MS-Off Ver
    Excel 2007
    Posts
    10

    Multiple Named Ranges Pasting Loop issue

    Hi Guys,

    I'm pasting values from one sheet to another based on multiple named ranges. Woks great when pasting one column but when i add multiple ranges, UFFF!...
    Read below...

    General Overview:

    I have a sample workbook attached, there are (2) sheets of importance.

    First is the sheet (EstSummary) where I have miraculously been able to hack together coding a button control to import data from the (Svc) sheet.

    The second Sheet (Svc) is a table of estimating service data that i have put together to input and price services.

    I have created a number of named ranges (SvcDesc, SvcHdr, SvcQty, SvcSid, etc..)..
    All the ranges above are single columns in the the Svc table and are dynamic leveraging the OFFSET function.

    First issue: (Code in the import button.)

    When I run this code to copy a single named range to the EstSummary Sheet, i have no issues pasting and re-pasting as the code checks for text and offsets one row past the next available cell row in that column.

    When I augment the code to reference multiple named ranges, the first paste works great. But then if i hit the button again, it freezes in the loop and i have to force the app to close. I will be duplicating this button to pull from additional sheets like the (Svc) sheet so I am looking to fix the loop. I am JUST learning VB so I'm still very basic with my understanding.

    Start CODE:======================================================
    Please Login or Register  to view this content.
    End Code==========================================================

    Second issueBlanks in the named range)

    In My SvcHdr named range there are sometimes blanks.

    The range should extend from C13:C55.. I use the header information for conditional formatting on both pages (H1 for example). So I may have it on C13 and again on C20, then C30.

    The problem is that when there are blanks in between the rows the dynamic range extends only to the second occurance of the H1 value.

    For instance, if I look at the range as it is set up above, it will show me that the range spans C13:C20.. It will not go past C20 to also cover C30 and down the rest of the column down to C55...

    I guess i could work around this by setting a sheet macro that will look at that range and fill that column with "-" or something so that there is a value in the field. I tried to but i couldn't get it to work.

    Any help would be appreciated.

    Thanks,

    P
    Attached Files Attached Files
    Last edited by pacman_d; 05-10-2010 at 07:09 AM. Reason: No Code Tags...

  2. #2
    Registered User
    Join Date
    04-30-2010
    Location
    NYC
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Multiple Named Ranges Pasting Loop issue

    Hey guys,

    Am i doing something wrong in my posts? Is there something that i am not doing or a rule that I am not following here? I guess i will give Mr Excel a shot.

    If you have any suggestions i would appreciate it.

    Best,

    P

  3. #3
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile Re: Multiple Named Ranges Pasting Loop issue

    Good morning pacman
    Quote Originally Posted by pacman_d View Post
    Am i doing something wrong in my posts? Is there something that i am not doing or a rule that I am not following here? I guess i will give Mr Excel a shot.
    Absolutely. The code tags (see below). Just a hint, but posting to MrExcel without code tags will result in your post being ignored, but no-one is likely to mention it. As stated below code without tags makes it harder to read.

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here

    DominicB
    Please familiarise yourself with the rules before posting. You can find them here.

  4. #4
    Registered User
    Join Date
    04-30-2010
    Location
    NYC
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Multiple Named Ranges Pasting Loop issue

    Hi Dominic,

    My ADD gets the better of me. I have adjusted the tags as recommended.

    Thanks for straightening me out!

    Best,

    P

  5. #5
    Registered User
    Join Date
    04-30-2010
    Location
    NYC
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Multiple Named Ranges Pasting Loop issue

    Make code more efficient

  6. #6
    Registered User
    Join Date
    04-30-2010
    Location
    NYC
    MS-Off Ver
    Excel 2007
    Posts
    10

    Talking Re: Multiple Named Ranges Pasting Loop issue

    Ok so I figured out the loop.

    ON MY OWN THANK YOU!!!..

    (Don't really know HOW i did it but I'm happy)

    Here's the working code to post multiple range columns to a single column without overwriting the previous text.

    I really thought i would get more help here but i guess there was too much going on with my post. I will move on to the next question regarding some worksheet change event code in a different post.

    THANKS!

    And Dominic, I PROMISE to use the "code tags" going forward.

    Best,

    P

    Please Login or Register  to view this content.
    Best,

    P

  7. #7
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,015

    Re: Multiple Named Ranges Pasting Loop issue

    And don't forget to post links to your cross-posts in other boards...
    Everyone who confuses correlation and causation ends up dead.

  8. #8
    Registered User
    Join Date
    04-30-2010
    Location
    NYC
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Multiple Named Ranges Pasting Loop issue

    Ok so on to my next challenge.

    I have some code set to execute on a worksheet change.

    There are two bits of code:

    The first batch sets the value of a deleted cell to 0..

    This helps me keep the integrity of my dynamic ranges as it seems that when they have blanks sporadically distributed, it omits actual data in the columns lower range.

    I am looking to target specific named range columns and have this execute only for those columns. Right now it does the whole sheet which creates a problem with the other piece of code for the first column. I will get to that next..

    Please Login or Register  to view this content.
    The second piece of code is validation for the first column where users enter some data. It looks at the column and makes certain that the user does not enter DUPES...


    They both work fine except that i don't want that first column's values to be set to 0 when a field is deleted.

    If someone were to delete 2 items from that first column, then the whole thing goes haywire as the first batch of code tries to set both vales to zero and the anti dupe code HATES with a LOOPING ferver the fact that there are two zeros in the column that its watching.

    So my mission is to accomplish two things:

    1. Restrict the CELL=0 code to specific columns using the named range
    2. Restrict the Anti Duping code to a single named range. (As it now goes all the way up and down column A..

    Thanks again!

    Best,

    P

  9. #9
    Registered User
    Join Date
    04-30-2010
    Location
    NYC
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Multiple Named Ranges Pasting Loop issue

    Here is the worksheet.

    Thanks,

    P
    Attached Files Attached Files

  10. #10
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,015

    Re: Multiple Named Ranges Pasting Loop issue

    X-post here.

  11. #11
    Registered User
    Join Date
    04-30-2010
    Location
    NYC
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Multiple Named Ranges Pasting Loop issue

    Not sure why i am being referred back to my same post in a different forum. (Where i had someone basically tell me that my loop was broken) Something i had already iterated in my post.

    No one looked at the code and made any recommendations. I have since solved the loop issue but have not figured out the worksheet validation stuff.

    If you could help me with that I would be most grateful.

    Best,

    P

  12. #12
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,015

    Re: Multiple Named Ranges Pasting Loop issue

    I wasn't referring you back there - it is a forum rule to provide a link if you cross-post in other forums (as well as being net etiquette). It saves people suggesting things you have tried elsewhere or working on something that has already been solved in another forum.

  13. #13
    Registered User
    Join Date
    04-30-2010
    Location
    NYC
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Multiple Named Ranges Pasting Loop issue

    Aha,

    Thanks for pointing that out. Although if I source a solution I always make sure I post the fix so that someone else can benefit.

    P

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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