Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Huge sheet into smaller sheets

Hi,

In my workbook, I must have as many sheets as there are days in a
month. In each sheet I have about 20 tables filled with different
types of data: text, dates, currency, etc. The entire workbook then
contains a month of daily data.

Every time I add a row/column, I split other tables on the same sheet.
The guy before me liked absolute references, so you can imagine it's a
nightmare to deal with.

Can anyone think of a way to optimize this ordeal? Ideally, I want
each table on a separate sheet, but then I'd have to save the whole
workbook as one day, and create a new workbook every day - ****er.
Thanks,



Mia

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default Huge sheet into smaller sheets

Option Explicit

Sub SplitAndBuild()

Dim wb As Workbook ' for output
Dim wsOut As Worksheet ' for output
Dim ws As Worksheet 'for daily loop
Dim source As Range
Dim index As Long ' loop counter for tables
' on each sheet set A1:Ann as the ranges of the tables
' eg A1 B5:D20
' eg A2 Table1

Dim tablename As String

' loop for each day -- ie each worksheet
For Each ws In ThisWorkbook.Worksheets

index = 1

'loop through each table
' creating a new worksheet for each
Do While ws.Cells(index, "A") < ""
tablename = ws.Cells(index, "A").Value
If tablename = "" Then Exit Do

' now copy over the ranges

source = ws.Range(tablename) ' a name would be better

'get a new worksheet
Set wsOut = GetSheet
wsOut.Name = tablename
wsOut.Range("B2").Value = tablename

With wsOut.Range("B4").Resize(source.Rows.Count,
source.Columns.Count)
.Value = source.Value
.Interior.ColorIndex = 34
End With

Loop

' ranges all copied, now save the workbook
' use the source worksheet's name?
wb.SaveAs "Month_" & ws.Name

wb.Close False ' its already saved, so just close it

Next ' worksheet - ie do the next day


Next




End Sub
Private Function GetSheet(wb As Workbook) As Worksheet
' create a workbook for the day
If wb Is Nothing Then
Set wb = Workbooks.Add(xlWBATWorksheet) ' with 1 sheet
Set GetSheet = wb.ActiveSheet ' and point at it
Else
With wb
Set GetSheet =
..Worksheets.Add(after:=.Worksheets(.Worksheets.Co unt))
End With
End If

End Function


Notes:
1) on each sheet, put a table starting at A1 with that sheets ranges that
need copying
2) whete the line for saving the output workbook is MONTH, chaneg this to
whatewver you like eg "APRIL_"
3) I assume that you'll process every worksheet. If there are more,
thenyou'll need to have something that can be checked - such as the worksheet
name - before processing, eg lets say each sheet's name is "Day 1" then "Day
2" etc, we could use

IF ws.Name LIKE "Day*" THEN '' and do getsheet & copy bit


HTH
Patrick Molloy
Microsoft Excel MVP



"Mia" wrote:

Hi,

In my workbook, I must have as many sheets as there are days in a
month. In each sheet I have about 20 tables filled with different
types of data: text, dates, currency, etc. The entire workbook then
contains a month of daily data.

Every time I add a row/column, I split other tables on the same sheet.
The guy before me liked absolute references, so you can imagine it's a
nightmare to deal with.

Can anyone think of a way to optimize this ordeal? Ideally, I want
each table on a separate sheet, but then I'd have to save the whole
workbook as one day, and create a new workbook every day - ****er.
Thanks,



Mia


Reply
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
Huge sheet into smaller sheets Mia Excel Discussion (Misc queries) 2 January 28th 05 11:36 PM
Huge sheet into smaller sheets Mia Links and Linking in Excel 1 January 28th 05 07:40 AM
Conversion of giant sheet into smaller ones Mia[_2_] Excel Programming 1 January 21st 05 12:45 AM
Excel 2000 importing huge ASCII files into different sheets Goran Stjepanovic Excel Programming 2 February 25th 04 09:30 AM
Split large sheet into several smaller sheets for emailing diverdon99 Excel Programming 3 December 9th 03 01:38 PM


All times are GMT +1. The time now is 03:23 PM.

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

About Us

"It's about Microsoft Excel"