+ Reply to Thread
Results 1 to 9 of 9

Need VBA code to match the value and split the data in the multiple sheets based on column

  1. #1
    Forum Contributor
    Join Date
    06-12-2013
    Location
    india
    MS-Off Ver
    Office 365
    Posts
    163

    Need VBA code to match the value and split the data in the multiple sheets based on column

    Hello Team,

    I am having the spread sheet where I have more than 70000 rows data with 25 columns in sheet1 and 6 columns and 60 rows in the sheet2, I need a code with the below options.

    1. In sheet1 insert one column (A column) and update the heading as Employee name.
    2. match the names from the column name "Invalid" from the sheet 1 and look up it in sheet 2 under the column name "Invalid Employee", then update the "Actual Employee Name" from sheet2 to sheet1 under column A which is named as Employee name.
    3. Filter the data in column A named "Employee name" and split the data in to multiple sheets (data needs to copy from B column to end of the column) and rename the sheets with the value given in the A column named "Employee name".
    4. In each sheet I need the total count under the Task 11 and auto sum in all the column names (Task 12, Task 13, Task 14) and result should be in bold letters.

    Note - Data needs to lookup/Match up based on the column name and not as per the column number, since some times the column will be interchange in the portal.

    I tried with the other codes given in other forums but I am getting some virtual memory error, not sure if this error occurs because I have more data but kindly help me to get the correct code which should not gives me any error while executing.

    Kindly do the needful at the earliest possible. I have attached both the data. Thank you.
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Need VBA code to match the value and split the data in the multiple sheets based on co

    Maybe:

    Please Login or Register  to view this content.

  3. #3
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,908

    Re: Need VBA code to match the value and split the data in the multiple sheets based on co

    Duplicate post see http://www.excelforum.com/showthread...18#post4471218

    Op has been sending me back and forth for already 7 days and now he posts same question again ??????????
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  4. #4
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,908

    Re: Need VBA code to match the value and split the data in the multiple sheets based on co

    @ John

    Check your Applications at the end of your code.

    @ Girish

    This is the last time.
    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    06-12-2013
    Location
    india
    MS-Off Ver
    Office 365
    Posts
    163

    Re: Need VBA code to match the value and split the data in the multiple sheets based on co

    Thank you very much, the code is working fine.....

  6. #6
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Need VBA code to match the value and split the data in the multiple sheets based on co

    @ bakerman2. Thanks - copying and pasting can get you into trouble sometimes.

  7. #7
    Forum Contributor
    Join Date
    06-12-2013
    Location
    india
    MS-Off Ver
    Office 365
    Posts
    163

    Re: Need VBA code to match the value and split the data in the multiple sheets based on co

    Hello bakerman/John,

    When I tried the given code to my actual sheet its not working, I am used code given below and also attached actual spread sheet. Please assist me if I am doing anything wrong. Thank you.

    Sub tst()

    With Application
    .Calculation = xlCalculationManual
    .ScreenUpdating = False
    End With
    With Sheets("Sheet1")
    .Columns(1).Insert
    .Cells(1).Value = "Employee Name"
    InvEmpName = Application.Match("Analysis Code", .Rows(1), 0)
    InvEmpName2 = Application.Match("Analysis Code", Sheets("Sheet2").Rows(1), 0)
    ActEmpName = Application.Match("TYPE", Sheets("Sheet2").Rows(1), 0)
    sn = .Cells(1).CurrentRegion.Value
    Set dic = CreateObject("scripting.dictionary")
    For i = 2 To UBound(sn)
    sn(i, 1) = Sheets("Sheet2").Cells(Application.Match(sn(i, InvEmpName), Sheets("Sheet2").Columns(InvEmpName2), 0), ActEmpName)
    x0 = dic.Item(sn(i, 1))
    Next
    .Cells(1).Resize(UBound(sn), UBound(sn, 2)) = sn
    End With
    For j = 0 To dic.Count - 1
    Sheets.Add , Sheets(Sheets.Count)
    With Sheets("Sheet1")
    .Cells(1).CurrentRegion.AutoFilter 1, dic.keys()(j)
    .AutoFilter.Range.SpecialCells(xlCellTypeVisible).Copy Sheets(Sheets.Count).Range("A1")
    End With
    With Sheets(Sheets.Count)
    .Columns(1).Delete
    .Name = dic.keys()(j)
    lr = .Cells(.Rows.Count, 1).End(xlUp).Row
    .Cells(lr + 1, 19).Formula = "=COUNTA(S2:S" & lr & ")"
    .Cells(lr + 1, 20).Formula = "=SUM(T2:T" & lr & ")"
    .Cells(lr + 1, 21).Formula = "=SUM(U2:U" & lr & ")"
    .Cells(lr + 1, 22).Formula = "=SUM(V2:V" & lr & ")"
    .Cells(lr + 1, 23).Formula = "=SUM(W2:W" & lr & ")"
    .Cells(lr + 1, 19).Resize(, 4).Font.Bold = True
    End With
    Next
    Sheets("Sheet1").AutoFilterMode = False
    With Application
    .Calculation = xlCalculationAutomatic
    .ScreenUpdating = True
    End With

    End Sub
    Attached Images Attached Images
    Attached Files Attached Files

  8. #8
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,520

    Re: Need VBA code to match the value and split the data in the multiple sheets based on co

    Give this a try on your first post workbook

    Please Login or Register  to view this content.
    This will work on your details uploaded workbook

    Please Login or Register  to view this content.
    Last edited by mike7952; 09-04-2016 at 04:38 AM.
    Thanks,
    Mike

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved.

  9. #9
    Forum Contributor
    Join Date
    06-12-2013
    Location
    india
    MS-Off Ver
    Office 365
    Posts
    163

    Re: Need VBA code to match the value and split the data in the multiple sheets based on co

    Thank you very much for all your help, really its working fine for me.

+ 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] Need vba to split data into multiple worksheets based on column of P & save wb with FY 16
    By johnmacpro in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-02-2016, 05:47 AM
  2. Need Macro code to split data split in 7 sheets based on variable rows in column A
    By Alija_21 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-31-2015, 08:03 AM
  3. [SOLVED] Macro to split data onto new sheets based on specific column
    By pauldaddyadams in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-17-2015, 12:53 PM
  4. [SOLVED] Split excel data into multiple sheets based on Employee ID
    By Preeti1309 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 04-21-2014, 02:33 AM
  5. Replies: 1
    Last Post: 04-12-2014, 04:03 PM
  6. Split Data Into Multiple Workbook Based On Column value with exisitng sheet
    By breadwinner in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-18-2013, 09:23 AM
  7. Split data into multiple documents based on specific column
    By v_nastey in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-16-2013, 08:56 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