Results 1 to 1 of 1

Copy part of a row to different new sheets based on text in a column

Threaded View

  1. #1
    Registered User
    Join Date
    12-07-2013
    Location
    noida, india
    MS-Off Ver
    Excel 2010
    Posts
    4

    Smile Copy part of a row to different new sheets based on text in a column

    Hi All,

    I am looking for help with my post. I had posted this in MrExcel help forum also but did not get a reply.
    Hence posting here.

    I have my data in a master sheet from Row A:K. The important columns are C & K
    Column C contains the Site Name and Column K has text like "Started", Completed etc.
    Based on the value of text in column K, I am looking for the corresponding columns data to be copied into a new sheet (Name based on the Site Name.

    I have a macro with me which copies the whole data of the corresponding data of the column to a new sheets based on the site, This is when I enter "Completed" in column K
    After the data is copied I want only the datain Column A, B,C, D & K to be visible.

    Hope I have been able to put this across clearly.

    My code is as under :

    Sub test()
    Dim i As Long, e, dic As Object
    Application.ScreenUpdating = False
    Set dic = CreateObject("Scripting.Dictionary")
    dic.CompareMode = 1
    With Sheets("master").Range("a12").CurrentRegion
    For i = 3 To .Rows.Count
    If .Cells(i, 11).Value = "Completed" Then
    For Each e In Split(.Cells(i, 3).Value, "/")
    If Not dic.exists(e) Then
    Set dic(e) = Union(.Rows(1), .Rows(i))
    Else
    Set dic(e) = Union(dic(e), .Rows(i))
    End If
    Next
    End If
    Next
    End With
    For Each e In dic
    If Not IsSheetExists(e) Then Sheets.Add(after:=Sheets(Sheets.Count)).Name = e
    With Sheets(e)
    .Cells.Delete
    dic(e).Copy
    .Cells(1).PasteSpecial xlPasteColumnWidths
    .Cells(1).PasteSpecial
    End With
    Next
    Application.CutCopyMode = False
    Application.ScreenUpdating = True
    End Sub

    Function IsSheetExists(ByVal txt As String) As Boolean
    On Error Resume Next
    IsSheetExists = Len(Sheets(txt).Name)
    On Error GoTo 0
    End Function

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] VB Code to find certain text in column and copy digit part in diff column
    By rmomin in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-09-2021, 07:12 AM
  2. [SOLVED] VB Code to Find Digit part in Text and copy in different column
    By rmomin in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-02-2021, 10:34 AM
  3. Copy part of text from on column to another and delete it.
    By Ralotoft in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-25-2021, 07:13 AM
  4. [SOLVED] To copy rows from one sheet to other sheets based on the first part of the named cell
    By JamesJohnson31 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-30-2014, 12:38 AM
  5. [SOLVED] Copy data from column to other sheets, based upon vlookup/criteria on column a
    By jedemeyer1 in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 03-27-2013, 04:01 AM
  6. Copy part of a row to a new sheet then delete whole row based on text value
    By badgerboy13 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-29-2012, 12:31 PM
  7. How to get column based upon text between 2 sheets
    By javajoemorgan in forum Excel General
    Replies: 0
    Last Post: 08-01-2011, 11:18 AM

Tags for this Thread

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