phatmankerrcap
MIS
Created the following script (from help and some helpful web sites).
But there is an error when trying to paste the data to a new workbook (have been messing around with it all day).
Any suggestions would be hugely appreciated.
Have highlighted in bold where I think the error is.
Many thanks
Phat
But there is an error when trying to paste the data to a new workbook (have been messing around with it all day).
Any suggestions would be hugely appreciated.
Have highlighted in bold where I think the error is.
Many thanks
Phat
Code:
Sub Split()
Dim r1 As Range
Dim wbNew As Workbook
With ThisWorkbook.Sheets(1)
Set c = Cells.Find("Split:", LookIn:=xlValues, LookAt:=xlPart)
If Not c Is Nothing Then
firstaddress = c.Address
Do
If firstaddress = c.Address Then
Set r1 = Range(Cells(1, 1), Cells(c.Row, Columns.Count))
[b] r1.EntireRow.Copy Destination:=wbNew.Sheets(1).Range("A1")
wbNew.Close SaveChanges:=True, Filename:=Mid(c, 8, 40)[/b]
Else
Set r1 = Range(Cells(d.Row + 1, 1), Cells(c.Row, Columns.Count))
r1.EntireRow.Copy Destination:=wbNew.Sheets(1).Range("A1")
wbNew.Close SaveChanges:=True, Filename:=Mid(c, 8, 40)
End If
Set d = c.Rows
Set c = Cells.FindNext(c)
Loop While Not c Is Nothing And c.Address <> firstaddress
End If
End With
End Sub