+ Reply to Thread
Results 1 to 5 of 5

Pull data from one workbook into another workbook

Hybrid View

  1. #1
    Valued Forum Contributor wenqq3's Avatar
    Join Date
    04-01-2013
    Location
    Malaysia
    MS-Off Ver
    Excel 2003
    Posts
    868

    Re: Pull data from one workbook into another workbook

    Sub split_REB()
        Dim wsName As String
        Dim startRow As Integer
        lastRow = ActiveSheet.Range("A" & Rows.Count).End(xlUp).Row
        
        With ActiveWorkbook.Worksheets("Sheet1").Sort
            .SetRange Range("A1:N" & lastRow)
            .Header = xlYes
            .Orientation = xlTopToBottom
            .Apply
        End With
    
        For i = 1 To lastRow
            If Cells(i, 5) <> Cells(i + 1, 5) And Not IsEmpty(Cells(i + 1, 5)) Then
                wsName = Cells(i + 1, 5)
                startRow = i + 1
                Range("A1:N1").Copy
                Sheets.Add
                ActiveSheet.Name = wsName
                ActiveSheet.Paste
                Range("A2").Select
                Sheets("Sheet1").Select
            End If
            
            If Cells(i + 1, 5) <> Cells(i + 2, 5) Then
                Range("A" & startRow & ":N" & i + 1).Select
                Selection.Copy
                Sheets(wsName).Select
                ActiveSheet.Paste
                Sheets("Sheet1").Select
            End If
        Next i
    End Sub
    Call this when you split data to new workbook
    -If the problem is solved, please mark your thread as Solved: Click Thread Tools above your first post, select "Mark your thread as Solved".

    -Always upload a workbook before start your question
    To attach a file, push the button with the paperclip (or scroll down to the Manage Attachments button), browse to the required file, and then push the Upload button.

    +++ If my answer(s) helped you, please add me reputation by click on * +++

  2. #2
    Registered User
    Join Date
    07-23-2014
    Location
    Malaysia
    MS-Off Ver
    2007
    Posts
    13

    Re: Pull data from one workbook into another workbook

    Quote Originally Posted by wenqq3 View Post
    Sub split_REB()
        Dim wsName As String
        Dim startRow As Integer
        lastRow = ActiveSheet.Range("A" & Rows.Count).End(xlUp).Row
        
        With ActiveWorkbook.Worksheets("Sheet1").Sort
            .SetRange Range("A1:N" & lastRow)
            .Header = xlYes
            .Orientation = xlTopToBottom
            .Apply
        End With
    
        For i = 1 To lastRow
            If Cells(i, 5) <> Cells(i + 1, 5) And Not IsEmpty(Cells(i + 1, 5)) Then
                wsName = Cells(i + 1, 5)
                startRow = i + 1
                Range("A1:N1").Copy
                Sheets.Add
                ActiveSheet.Name = wsName
                ActiveSheet.Paste
                Range("A2").Select
                Sheets("Sheet1").Select
            End If
            
            If Cells(i + 1, 5) <> Cells(i + 2, 5) Then
                Range("A" & startRow & ":N" & i + 1).Select
                Selection.Copy
                Sheets(wsName).Select
                ActiveSheet.Paste
                Sheets("Sheet1").Select
            End If
        Next i
    End Sub
    Call this when you split data to new workbook
    Its really help me yeayy..it run exactly like what i want..TQ so much u save my life :D

+ 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. Macro to push pull data from a workbook by name to a master workbook
    By gizmojeff in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-25-2014, 11:36 AM
  2. Pull Data from one workbook to another
    By velben27 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-06-2013, 12:59 PM
  3. Replies: 0
    Last Post: 04-03-2013, 01:58 AM
  4. [SOLVED] Master workbook to pull data from second workbook into seperate sheet
    By djm601 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 01-16-2013, 09:24 AM
  5. Replies: 3
    Last Post: 05-22-2008, 05:55 PM

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