Results 1 to 5 of 5

Sending Information to a new Workbook - Code

Threaded View

  1. #1
    Registered User
    Join Date
    05-11-2009
    Location
    GA
    MS-Off Ver
    Excel 2003
    Posts
    14

    Sending Information to a new Workbook - Code

    I am trying to get this to sort out to a new workbook instead of a worksheet. There are only two components in C column, so there should only be 2 new workbooks created. I am a little unfamiliar with the terminology for the workbooks. Thank you.

    Sub SplitOut()
      Dim DataSH As Worksheet, OutSH As Worksheet
      Set DataSH = Sheets("Input")
      DataSH.Activate
      lastrow = Cells(Rows.Count, "C").End(xlUp).Row
      For Each ce In Range("C2:C" & lastrow)
        Application.StatusBar = "Actioning " & ce.Row & " of " & lastrow
        On Error Resume Next
        Set OutSH = Nothing
        Set OutSH = Sheets(ce.Value)
        On Error GoTo 0
        If OutSH Is Nothing Then 'the sheet doesn't exist
          Sheets.Add after:=Sheets(Sheets.Count)
          ActiveSheet.Name = ce.Value
          ActiveSheet.Range("A1:N1").Value = DataSH.Range("A1:N1").Value
          Set OutSH = ActiveSheet
        End If
        outrow = OutSH.Cells(Rows.Count, "D").End(xlUp).Offset(1, 0).Row
        ce.EntireRow.Copy Destination:=OutSH.Cells(outrow, 1)
      Next ce
      Application.StatusBar = False
      MsgBox "Done"
    End Sub
    Last edited by cwalker6; 05-20-2009 at 04:32 PM.

Thread Information

Users Browsing this Thread

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

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