+ Reply to Thread
Results 1 to 27 of 27

Formula to allocate name and count in col 'F'.

Hybrid View

  1. #1
    Forum Contributor visha_1984's Avatar
    Join Date
    11-27-2012
    Location
    Pune,India
    MS-Off Ver
    Excel 2013
    Posts
    309

    Formula to allocate name and count in col 'F'.

    Hi Forum team,

    I have just working on worksheet i need formula to Drag Allocation in DATA file Cp and Qty wise in col 'F' and insert Blank row after Cp name in col F.

    I have attached sample data file. any help Greatly appriciate.

    Thanks in advance.
    Attached Files Attached Files
    Happy to Help

    VISHA

    Click *, if the suggestion helps you!
    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>> "Mark your thread as Solved"

  2. #2
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: Formula to allocate name and count in col 'F'.

    Based on your data size it is better to go for VBA solution.

    Please confirm whether VBA solution is ok for you?


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  3. #3
    Forum Contributor visha_1984's Avatar
    Join Date
    11-27-2012
    Location
    Pune,India
    MS-Off Ver
    Excel 2013
    Posts
    309

    Re: Formula to allocate name and count in col 'F'.

    Quote Originally Posted by :) Sixthsense :) View Post
    Based on your data size it is better to go for VBA solution.

    Please confirm whether VBA solution is ok for you?
    Hi,Sixthsense

    Ok no problem .

  4. #4
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: Formula to allocate name and count in col 'F'.

    Try the below code….


    How to install your new code
    1. Copy the Excel VBA code
    2. Select the workbook in which you want to store the Excel VBA code
    3. Press Alt+F11 to open the Visual Basic Editor
    4. Choose Insert > Module
    5. Edit > Paste the macro into the module that appeared
    6. Close the VBEditor
    7. Save your workbook (Excel 2007+ select a macro-enabled file format, like *.xlsm)

    To run the Excel VBA code:
    1. Press Alt-F8 to open the macro list
    2. Select a macro in the list
    3. Click the Run button

    Sub ArrangeData()
    Dim rData As Range, rAllocation As Range, lRw As Long, lCopy As Long, lStart As Long
    
    With Sheets("DATA")
        lRw = .Cells(Rows.Count, "A").End(xlUp).Row
        Set rData = .Range("A1:H" & lRw)
    End With
    
    With Sheets("ALLOCATION")
        lRw = .Cells(Rows.Count, "A").End(xlUp).Row
        Set rAllocation = .Range("A1:C" & lRw)
    End With
    
    Application.ScreenUpdating = False
    
    Sheets.Add , Sheets(rAllocation.Parent.Name)
    
    For i = 2 To lRw
        If i = 2 Then lStart = 1
        lCopy = rAllocation.Columns(3).Cells(i).Value
        rData.Rows(lStart).Resize(lCopy).Copy Cells(Rows.Count, "A").End(xlUp)(3)
        Cells(lStart + (i), "F").Resize(lCopy).Value = rAllocation.Columns(2).Cells(i).Value
        lStart = lStart + lCopy
    Next i
    
    Rows("1:2").Delete
    Range("A:H").Columns.AutoFit
    
    Application.ScreenUpdating = True
    
    End Sub

  5. #5
    Forum Contributor visha_1984's Avatar
    Join Date
    11-27-2012
    Location
    Pune,India
    MS-Off Ver
    Excel 2013
    Posts
    309

    Re: Formula to allocate name and count in col 'F'.

    Hi,Sixthsense

    code Allocate cp in DATA sheet correctly but need to insert row after cp name for whole row ,and one more thing after allocation code drag again cp name.

  6. #6
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: Formula to allocate name and count in col 'F'.

    The provided code working fine for in the file which you have attached in Post #1

  7. #7
    Forum Contributor visha_1984's Avatar
    Join Date
    11-27-2012
    Location
    Pune,India
    MS-Off Ver
    Excel 2013
    Posts
    309

    Re: Formula to allocate name and count in col 'F'.

    Quote Originally Posted by :) Sixthsense :) View Post
    The provided code working fine for in the file which you have attached in Post #1
    Ok got it Sixthsense Thank u very much.
    Last edited by visha_1984; 11-25-2013 at 04:48 AM.

  8. #8
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: Formula to allocate name and count in col 'F'.

    Glad it helps you and thanks for the feedback and rep

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

  9. #9
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: Formula to allocate name and count in col 'F'.

    Try the below code...

    You have to select the Data range and Allocation Range Manually. Made it user defined range so than you can select your desired range on which the macro needs to be performed.

    Sub ArrangeData()
    Dim rData As Range, rAllocation As Range, rPaste As Range
    Dim lRw As Long, lCopy As Long, lStart As Long
    
    On Error Resume Next
    Set rData = Application.InputBox("Select The DATA RAMGE", "Input DATA RANGE Required", , , , , , 8)
    
    If rData Is Nothing Then GoTo InValidRange
    
    Set rAllocation = Application.InputBox("Select The ALLOCATION RANGE" _
                    & vbCrLf & vbCrLf & vbCrLf & "******EXCLUDING HEADER******", _
                    "ALLOCATION RANGE Required" & vbCrLf & vbCrLf, , , , , , 8)
    
    If rAllocation Is Nothing Then GoTo InValidRange
    
    On Error GoTo 0
    Application.ScreenUpdating = False
    
    Sheets("Output").Select
    
    For i = 1 To rAllocation.Rows.Count
        Set rPaste = Cells(Rows.Count, "A").End(xlUp)
        If rPaste.Row <> 1 Then Set rPaste = Cells(Rows.Count, "A").End(xlUp).Offset(2)
        If i = 1 Then lStart = rData.Row
        lCopy = rAllocation.Columns(3).Cells(i).Value
        rData.Rows(lStart).Resize(lCopy).Copy
        With rPaste
            .PasteSpecial xlPasteAll
            .Offset(, 5).Resize(lCopy).Value = rAllocation.Columns(2).Cells(i).Value
        End With
        lStart = lStart + lCopy
    Next i
    
    Range("A:H").Columns.AutoFit
    
    Application.ScreenUpdating = True
    
    Exit Sub
    
    InValidRange:
        MsgBox "Invalid Input Selection Made/Provided", vbCritical, "Task Failed, Run It Again"
    
    End Sub

  10. #10
    Forum Contributor visha_1984's Avatar
    Join Date
    11-27-2012
    Location
    Pune,India
    MS-Off Ver
    Excel 2013
    Posts
    309

    Re: Formula to allocate name and count in col 'F'.

    Great Sixthsense,

    It works fantastic thanku very much.
    U save My 3 workinghours per day.

    cheers.'''.

    All the best.

  11. #11
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: Formula to allocate name and count in col 'F'.

    Glad it helps you and once again thanks for the feedback

  12. #12
    Forum Contributor visha_1984's Avatar
    Join Date
    11-27-2012
    Location
    Pune,India
    MS-Off Ver
    Excel 2013
    Posts
    309

    Re: Formula to allocate name and count in col 'F'.

    Hi Seixthsense,

    I have one issue while alocating cp allocation,If in DATA sheet there is 2 or 3 Break in all col then what should i do and code allocating '-1' qty in output folder.
    pls suggest

  13. #13
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: Formula to allocate name and count in col 'F'.

    Please show a sample workbook to know in which circumstances the provided code is getting failed and for my testing purpose too...

  14. #14
    Forum Contributor visha_1984's Avatar
    Join Date
    11-27-2012
    Location
    Pune,India
    MS-Off Ver
    Excel 2013
    Posts
    309

    Re: Formula to allocate name and count in col 'F'.

    Hi Sixthsense,

    pls help if i select range manually for second lot code should drag from selected range, but i macro code draging another range.

    pls help me out i have attached sample workbook.
    Attached Files Attached Files

  15. #15
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: Formula to allocate name and count in col 'F'.

    Oopsss.... Just replace the below line

    If i = 1 Then lStart = rData.Row
    With

    If i = 1 Then lStart = 1

  16. #16
    Forum Contributor visha_1984's Avatar
    Join Date
    11-27-2012
    Location
    Pune,India
    MS-Off Ver
    Excel 2013
    Posts
    309

    Re: Formula to allocate name and count in col 'F'.

    Thanks once again Sixthsense.
    Good Day.

+ 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. [SOLVED] Count / Allocate number in list
    By Starkey in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-22-2013, 08:53 PM
  2. Trying to add to a Rand formula to allocate tasks/units
    By Holly123 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 06-11-2013, 10:44 PM
  3. Replies: 0
    Last Post: 05-10-2013, 08:08 AM
  4. [SOLVED] Formula help : Sort by number range and then allocate different coloured cells
    By gandk in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 10-22-2012, 01:38 AM
  5. formula to allocate points to positions in a race
    By SEVKN in forum Excel General
    Replies: 2
    Last Post: 10-14-2008, 02:52 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