+ Reply to Thread
Results 1 to 15 of 15

Allocation using VBA

  1. #1
    Registered User
    Join Date
    03-29-2011
    Location
    Bangalore
    MS-Off Ver
    Excel 2003
    Posts
    9

    Allocation using VBA

    Hello,

    I have around 1000 row line items and in another col I have 20 names. I want to allocate the 1000 rows equally among the 20 people using a command button.

    Request your help!
    Last edited by naveenhs5; 11-19-2011 at 10:23 AM.

  2. #2
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Allocation using VBA

    naveenhs5

    Welcome to the forum

    To best describe or illustrate your problem you would be better off attaching a dummy workbook, the workbook should contain the same structure and some dummy data of the same type as the type you have in your real workbook - so, if a cell contains numbers & letters in this format abc-123 then that should be reflected in the dummy workbook.

    If needed supply a before and after sheet in the workbook so the person helping you can see what you are trying to achieve.

    Doing this will ensure you get the result you need!
    If the solution helped please donate to RSPCA

    Site worth visiting: Rabbitohs

  3. #3
    Registered User
    Join Date
    03-29-2011
    Location
    Bangalore
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: Allocation using VBA

    I have attached the file!
    Attached Files Attached Files

  4. #4
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Allocation using VBA

    hi, naveenhs5, hope it helps, run code "test"
    Attached Files Attached Files
    Last edited by watersev; 11-17-2011 at 08:54 AM.

  5. #5
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Allocation using VBA

    Hi naveenhs5,
    You dont need a macro
    =OFFSET(F$2,IF(MOD((ROW()-1)/D$1,1)*D$1=0,D$1-1,(MOD((ROW()-1)/D$1,1)*D$1)-1),0)
    to fill the column
    or create a table
    =IF($F2<>"",OFFSET($A$1,(ROW()-1)+($D$1*(COLUMN()-7)),0),"")
    Attached Files Attached Files

  6. #6
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Allocation using VBA

    I didnt understand your use of "Rept" in the first row in the excel sheet. This will be a good learning for me. Can you please explain?

  7. #7
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Allocation using VBA

    Ops it should have been
    =OFFSET(F$2,IF(MOD((ROW()-1)/D$1,1)*D$1=0,D$1-1,ROUND(MOD((ROW()-1)/D$1,1)*D$1,1)-1),0)

    REPT ? where
    Attached Files Attached Files

  8. #8
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Allocation using VBA

    O rept
    =LOOKUP(REPT("z",255),F2:F30)
    Looks up the last string in a column

  9. #9
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Allocation using VBA

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save

  10. #10
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Allocation using VBA

    or to explain more

    To get the LAST text value in a list
    =LOOKUP(REPT("z",255),F2:F30)

    Use of REPT function
    REPT("z",255) = A string consisting of 255 "z"s and is the largest string Excel can handle.

    so when lookup can find it, it defaults to the last value in list

  11. #11
    Registered User
    Join Date
    03-29-2011
    Location
    Bangalore
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: Allocation using VBA

    Hi Pike,

    Your formula is working fine and solved the issue....thank u very much!

    Is it possible to just explain in brief how ur formula works?....just want to explore Excel.


    Thanks!

  12. #12
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Allocation using VBA

    which one?

  13. #13
    Registered User
    Join Date
    03-29-2011
    Location
    Bangalore
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: Allocation using VBA

    this one - =OFFSET(F$2,IF(MOD((ROW()-1)/D$1,1)*D$1=0,D$1-1,ROUND(MOD((ROW()-1)/D$1,1)*D$1,1)-1),0)

  14. #14
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Allocation using VBA

    hi naveenhs5

    =OFFSET(F$2,IF(MOD((ROW()-1)/D$1,1)*D$1=0,D$1-1,ROUND(MOD((ROW()-1)/D$1,1)*D$1,1)-1),0)

    offset(cell to offset, Rows, Columns ) and
    If(Test Boolean argument, value for true, value for false)
    But the interesting is
    ROUND(MOD((ROW()-1)/D$1,1)*D$1
    It uses the remainder of the division of a number by constant divisor times the divisor
    It’s a divisor rule which I can’t remember the name of
    It creates the number sequence
    So basic we create a repeating set number 0-7 from any row number to offset from F2
    You can see it in action if you click in the cell with formula and the good to the formula tool bar and click evaluate formula

  15. #15
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Allocation using VBA

    ROUND(MOD((ROW()-1)/D$1,1)*D$1
    is a Modulo operation

+ 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