+ Reply to Thread
Results 1 to 11 of 11

Code Consolodating

  1. #1
    Registered User
    Join Date
    10-02-2009
    Location
    NY
    MS-Off Ver
    Excel 2003
    Posts
    72

    Code Consolodating

    Can someone help me round this code down

    Please Login or Register  to view this content.
    I have all these Ranges called RANGE1, RANGE2, ETC and copy these three lines all day which is cumbersome. Is it possible if I know how many ranges of data I have to consolodate this code or use the names of the Ranges on the 1st line with some trick..?

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Code Consolodating

    What's in the first row of the ranges?

    Also, where are they in relation to each other?

    If they are column ranges next to each other and have the same length you could perhaps use this,
    Please Login or Register  to view this content.
    or perhaps this.
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    10-02-2009
    Location
    NY
    MS-Off Ver
    Excel 2003
    Posts
    72

    Re: Code Consolodating

    They are Ranges on top of each other in the same column ALWAYS . Some vary in size.

    EXAMPLES
    RANGE 1:CELL A2,A3,A4
    RANGE 2:CELL A7,A8,A9,A10
    RANGE 3: CELL A15,A16,A17,A18,A19

    I wil try what you did see what happens....

    ETC..

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Code Consolodating

    The 2nd code I posted will work if the ranges are like that, but I'm not sure it will fill the ranges with the correct values.

    Mind you I don't actually know what values they are supposed to be filled with.

  5. #5
    Registered User
    Join Date
    10-02-2009
    Location
    NY
    MS-Off Ver
    Excel 2003
    Posts
    72

    Re: Code Consolodating

    Please Login or Register  to view this content.
    This is the code that CAN work. Now in this do you have only RANGE1 called out or are there multiple? If not where do you add the other Ranges in that 1st line. Then I might have what I am looking for!

    it was based off this thread I created a week ago to finish it all off..

    http://www.excelforum.com/excel-prog...ng-series.html

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Code Consolodating

    That code won't work, it assumed the 3 ranges were side by side and of the same size.

    The second code does work, but I don't know if it's filling with the right values because you still haven't said what values the ranges should be filled with.

  7. #7
    Registered User
    Join Date
    10-02-2009
    Location
    NY
    MS-Off Ver
    Excel 2003
    Posts
    72

    Re: Code Consolodating

    Quote Originally Posted by Norie View Post
    That code won't work, it assumed the 3 ranges were side by side and of the same size.

    The second code does work, but I don't know if it's filling with the right values because you still haven't said what values the ranges should be filled with.
    1
    +2
    3
    +4
    5
    6
    7
    8
    9
    +10


    1
    2
    2.1
    2.2
    3
    4
    4.1
    4.2
    4.3
    5
    6
    7
    8
    9
    10
    10.1
    10.2
    10.3
    10.4

    Example: + means there is a level 2 group of cells. The Ranges are basically(2,2.1,2.2) & (4,4.1,4.2,4.3) & (10,10.1,10.2,10.3,10.4) <--RANGE1,RANGE2, RANGE3

    I will try the 2nd code again...

  8. #8
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Code Consolodating

    Sorry, you've lost me.

    That data doesn't seem to correspond to the ranges or code you've posted.

  9. #9
    Registered User
    Join Date
    10-02-2009
    Location
    NY
    MS-Off Ver
    Excel 2003
    Posts
    72

    Re: Code Consolodating

    See the attachment with the macro inside. Make sure to leave 1 in the 1st cell always!
    1. Clear/delete the values below 1
    2. Close the level to 1
    3. Run the Macro

    Now I want to consoldate the code repeated multiple times inside the VBA editor...
    Attached Files Attached Files
    Last edited by Jbelle7435; 04-16-2013 at 12:06 PM.

  10. #10
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Code Consolodating

    I really don't know what you mean by 'consolidating', do you mean shorten the code?
    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    10-02-2009
    Location
    NY
    MS-Off Ver
    Excel 2003
    Posts
    72

    Re: Code Consolodating

    Yes SHORTEN THE CODE! I will always keep on adding ranges to whatever but did not want to copy those 3 lines over and over and I knew it could be done but I am not an expert coder...

    I will try this above and see if we have a winner!

    SKILLZ....

    I incorporated it into what I want and it works!! I knew the For Loop was an Idea but I did so little VBA with this via Record button/Mouse Click Commands. I guess you need the middle ground to get your perfect Macro with neat looking Code! Thanks

    my favorite part is the code: .Range("RANGE" & I) <--RANGE1, RANGE2,RANGE3,ETC.... I would never known how to do this! Now I do.
    Last edited by Jbelle7435; 04-16-2013 at 12:58 PM.

+ 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