LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default Export to multiple workbooks - row limit

This is along the lines of a previous post, but different enouph to post in a new thread, I think. Here is my situation. I have the following code worked out. It takes a workbook of multiple pages and breaks it out into multiple workbooks based on the date of the data in each row. Those dates come from a list in another workbook

Sub Test2(
Application.ScreenUpdating = Fals
Application.DisplayAlerts = Fals
Dim MyPath As Strin
Dim sh As Workshee
Dim i As Lon
Dim cLastRow As Lon
Windows("TIPSData.xls").Activat
Sheets("DateSheet").Selec
Set sh = ActiveWorkbook.ActiveShee

cLastRow = Cells(Rows.Count, "A").End(xlUp).Ro
For i = 1 To cLastRo
MonthlyFiles Left(sh.Cells(i, "A").Value, Len(sh.Cells(i, "A").Value)
Next

End Su

Sub MonthlyFiles(Month As String
Dim ws As Workshee
'Creat
Workbooks.Ad
Sheets("Sheet2").Selec
ActiveWindow.SelectedSheets.Delet
Sheets("Sheet3").Selec
ActiveWindow.SelectedSheets.Delet
With ActiveWorkboo
.SaveAs FileName:=ThisWorkbook.Path
& "\ProgramData\FileData\ConvertedData\Monthly\Repor t4\" & Month & ".xls",
FileFormat:=xlNormal,
Password:="",
WriteResPassword:="",
ReadOnlyRecommended:=False,
CreateBackup:=Fals
End Wit
Windows("Report4.xls").Activat
For Each ws In ActiveWorkbook.Worksheet
ws.Activat
With w
.Columns("A:R").AutoFilter Field:=10, Criteria1:=Mont
.Columns("A:R").SpecialCells(xlCellTypeVisible).Co p
Windows(Month & ".xls").Activat
LastRow = Cells(Rows.Count, "A").End(xlUp).Ro
Range("A" & LastRow + 1).PasteSpecia
Windows("Report4.xls").Activat
End Wit
Next w
End Su

My two issues are, is there a way in the bottom portion where I copy all visable cells into the new workbook with only one worksheet (since I remove the others). Is there a way to make this so that if the total amount of data exceeds the row limit, then it will create a new page and paste into that? I asked a similar question before and got the following code, but can't figure out a way to merge these two. I am working on it, but so far no luck

Option Explici
Sub CombineWorkbooks(

Dim LastRow As Lon
Dim basebook As Workboo
Dim i As Lon
Dim mybook As Workboo
Dim DestCell As Rang
Dim RngToCopy As Rang

With Applicatio
.DisplayAlerts = Fals
.EnableEvents = Fals
.ScreenUpdating = Fals
End Wit

With Application.FileSearc
.NewSearc
'Change this to your director
.LookIn = ThisWorkbook.Path & "\ProgramData\"
.SearchSubFolders = Fals
.FileType = msoFileTypeExcelWorkbook
If .Execute() 0 The
Set basebook = Workbooks.Open(.FoundFiles(1)

With basebook.Worksheets(1
Set DestCell = .Cells(.Rows.Count, "A").End(xlUp
End Wit

For i = 2 To .FoundFiles.Coun
Set mybook = Workbooks.Open(.FoundFiles(i)
With ActiveShee
'column R = 18th colum
Set RngToCopy = .Range("a1:R" &
.Cells(.Rows.Count, "A").End(xlUp).Row
End Wit

If (DestCell.Row + RngToCopy.Rows.Count)
< DestCell.Parent.Rows.Count The
'ok to paste, just come down one
Set DestCell = DestCell.Offset(1, 0
Els
'too many rows, make a new shee
Set DestCell = basebook.Worksheets.Add.Range("a1"
End I

RngToCopy.Copy
Destination:=DestCel
Set DestCell = DestCell.Offset(RngToCopy.Rows.Count
mybook.Clos
Next
'ChDir ThisWorkbook.Path & "\ProgramData\FileData\Report\
ActiveWorkbook.SaveAs
Filename:=ThisWorkbook.Path & "\ProgramData\FileData\Report\"
& "Report1.xls", _
FileFormat:=xlText, CreateBackup:=False

'ActiveWorkbook.Close savechanges:=false 'just saved
End If
End With

With Application
.DisplayAlerts = True
.EnableEvents = True
End With

End Sub


Also is there a way to not copy and paste the column headers?

Thanks for your assistance

Jim
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel text export limit - 1024 per line (not cell), workaround? Dave Excel Discussion (Misc queries) 11 August 11th 09 04:41 PM
export multiple sheets to multiple excel files Tanya Excel Discussion (Misc queries) 1 April 20th 09 08:57 PM
combine multiple workbooks? overcome 255 character limit? Wayne Excel Worksheet Functions 3 March 6th 09 08:38 PM
Export Data from many workbooks with many sheets to Access johnb Excel Discussion (Misc queries) 2 October 3rd 08 11:39 AM
Excel 2007 export as XML size limit/bug Erik C. Nielsen Excel Discussion (Misc queries) 0 December 26th 07 07:09 PM


All times are GMT +1. The time now is 11:23 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"