Move data into new sheet

meakashgfx

New Member
Joined
Dec 9, 2014
Messages
33
Hi,

I have almost 70 employees monthly login/Logout data in one sheet.

I want to create new sheet with each unique value and move the monthly data into there.

Here is a screenshot: Screenshot by Lightshot
Is it possible to make it by using ASAP utilities? or Please help me with the VBA.

Thanks in Advance!
Akash
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Hi,

Please see code below with following caveats:
- code deletes cells on existing Name sheets
- code adds new Name sheets
- so it assumes all data are on sheet "Shahadat"
- code does not affect other (not Name related) sheets

Code:
Sub Move_data_into_new_sheet()


Dim D As Object, i  As Long, X, Rng As Range, Sh As Worksheet, Van() As Boolean


Application.ScreenUpdating = False


Set Rng = ThisWorkbook.Sheets("Shahadat").UsedRange
Set D = CreateObject("Scripting.Dictionary")


'Read unique values in column A to Dictionary object
For i = 2 To Rng.Rows.Count
    D(CStr(Rng.Cells(i, 1))) = ""
Next i


ReDim Van(i = 0 To D.Count - 1)
X = D.keys


'Clear cells for existing Name sheets and add new Name sheets:
For Each Sh In ThisWorkbook.Worksheets
    For i = 0 To D.Count - 1
        If Sh.Name = X(i) Then
            Van(i) = True
            Exit For
        End If
    Next i
Next Sh
For i = 0 To D.Count - 1
    If Van(i) Then
        Sheets(X(i)).Cells.Clear
    Else
        Sheets.Add , Sheets(Sheets.Count)
        ActiveSheet.Name = X(i)
    End If
Next i


'Filter Name on sheet "Shahadat" and copy-paste content to individual Name sheets:
If Sheets("Shahadat").AutoFilterMode = True Then Sheets("Shahadat").AutoFilterMode = False
Rng.AutoFilter


For i = 0 To D.Count - 1
    Rng.AutoFilter 1, X(i), xlFilterValues
    Rng.SpecialCells(xlCellTypeVisible).Copy Sheets(X(i)).Range("a1")
Next i




Application.ScreenUpdating = True


End Sub

I hope it'll work for you as well.

Regards,
 
Last edited:
Upvote 0
Try this code...

Note: Code does NOT check for duplicate sheet names! If a duplicate is encountered, it will debug!

Code:
Sub SplitToSheet()
Dim sh As Worksheet
Dim r As Range
Dim i As Integer
    Application.ScreenUpdating = False
    Set sh = ActiveSheet
    sh.Range("A1").CurrentRegion.Columns(1).AdvancedFilter Action:=xlFilterCopy, CopyToRange:=Range("F1"), Unique:=True
    Set r = Range("F2", Cells(Rows.Count, "F").End(xlUp))
    For i = r.Rows.Count To 1 Step -1
        Sheets.Add(After:=ActiveSheet).Name = sh.Range("F2").Value
        sh.Range("A1").CurrentRegion.AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:=sh.Range("F1:F2"), Unique:=False
        sh.Range("A1").CurrentRegion.Copy ActiveSheet.Range("A1")
        ActiveSheet.Range("A1").CurrentRegion.Columns.AutoFit
        sh.ShowAllData
        sh.Range("F2").Delete Shift:=xlUp
    Next i
    sh.Select
    sh.Columns("F:F").Delete
    Application.ScreenUpdating = True
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,849
Members
452,361
Latest member
d3ad3y3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top