+ Reply to Thread
Results 1 to 4 of 4

Filtering Data and copying the rows back to the Summary Page

Hybrid View

  1. #1
    Registered User
    Join Date
    02-04-2014
    Location
    Milton Keynes
    MS-Off Ver
    Excel 2013
    Posts
    2

    Filtering Data and copying the rows back to the Summary Page

    Hi All,

    My first post here so please excuse any ignorance.

    I have a spreadsheet of raw data that has been downloaded in Excel. In Column N there are different site numbers.

    I want to use a new Sheet for each site. Using a formulae I want to filter the data for each site and then copy the entire row to the relevant site`s page.

    So I should end up with a sheet for each page and allthe data sorted correctly?

    Can anyone help?

  2. #2
    Registered User
    Join Date
    05-21-2012
    Location
    Coimbatore, India
    MS-Off Ver
    Excel 2010
    Posts
    73

    Re: Filtering Data and copying the rows back to the Summary Page

    Hi, Try this code.
    Sub split_data()
    
    Dim lr As Long
    Dim ws As Worksheet
    Dim vcol, i As Integer
    Dim icol As Long
    Dim myarr As Variant
    Dim title As String
    Dim titlerow As Integer
    
    vcol = 14        'CHANGE THE COLUMN NUMBER AS PER YOUR NEED
    
    Set ws = Sheets("sheet1")        'CHANGE THE SHEET NAME AS PER YOUR NEED
    
    lr = ws.Cells(ws.Rows.Count, vcol).End(xlUp).Row
    
    title = "A1:Z1"             'CHANGE THE TITLE ROW AS PER YOUR NEED
    titlerow = ws.Range(title).Cells(1).Row
    icol = ws.Columns.Count
    
    ws.Cells(1, icol) = "Unique"
    
    For i = 2 To lr
    On Error Resume Next
    If ws.Cells(i, vcol) <> "" And Application.WorksheetFunction.Match(ws.Cells(i, vcol), ws.Columns(icol), 0) = 0 Then
    ws.Cells(ws.Rows.Count, icol).End(xlUp).Offset(1) = ws.Cells(i, vcol)
    End If
    Next
    
    myarr = Application.WorksheetFunction.Transpose(ws.Columns(icol).SpecialCells(xlCellTypeConstants))
    
    ws.Columns(icol).Clear
    
    For i = 2 To UBound(myarr)
    ws.Range(title).AutoFilter field:=vcol, Criteria1:=myarr(i) & ""
    
    If Not Evaluate("=ISREF('" & myarr(i) & "'!A1)") Then
    Sheets.Add(after:=Worksheets(Worksheets.Count)).Name = myarr(i) & ""
    Else
    Sheets(myarr(i) & "").Move after:=Worksheets(Worksheets.Count)
    End If
    
    ws.Range("A" & titlerow & ":A" & lr).EntireRow.Copy Sheets(myarr(i) & "").Range("A1")
    Sheets(myarr(i) & "").Columns.AutoFit
    Next
    
    ws.AutoFilterMode = False
    ws.Activate
    
    End Sub
    Thanks
    Babu.S

  3. #3
    Registered User
    Join Date
    02-04-2014
    Location
    Milton Keynes
    MS-Off Ver
    Excel 2013
    Posts
    2

    Re: Filtering Data and copying the rows back to the Summary Page

    Hi,
    Sorry but how do I enter that code? Normally i enter formulae into the cells. Sorry my knowledge on Excel isnt very good.

  4. #4
    Registered User
    Join Date
    05-21-2012
    Location
    Coimbatore, India
    MS-Off Ver
    Excel 2010
    Posts
    73

    Re: Filtering Data and copying the rows back to the Summary Page

    1.Copy the sample code that you want to use
    2.Open the workbook in which you want to add the code
    3.Hold the Alt key, and press the F11 key, to open the Visual Basic Editor
    4.Choose Insert | Module
    5.Where the cursor is flashing, choose Edit | Paste
    save and close,
    back on excel file
    6.On the Excel Ribbon, click the View tab
    7.At the far right, click Macros
    8.Select a macro in the list, and click the Run button

+ 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. Replies: 9
    Last Post: 04-30-2013, 03:21 AM
  2. [SOLVED] For each new sheet created, create a hyperlink back to a summary page
    By atcsmh in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-18-2013, 09:09 AM
  3. Replies: 1
    Last Post: 05-21-2012, 03:01 AM
  4. Inserting Rows Doesn't Adjust Formula on Summary Page
    By Big_Tater in forum Excel General
    Replies: 1
    Last Post: 04-20-2010, 05:50 AM
  5. Copying rows which satisfies a filtering condition
    By blurtoad in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-06-2007, 11:31 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