Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

STL - Formerly Best Training Solutions Through Learning
TrustPilot
Excellent
Request Callback We will call you back
0207 987 3777 Call for assistance
Your Basket Basket is empty
workbooks worksheets

Forum home » Delegate support and help forum » Microsoft Excel VBA Training and help » Workbooks & worksheets

Workbooks & worksheets

ResolvedVersion 2003

Jill has attended:
Excel VBA Intro Intermediate course

Workbooks & worksheets

How can I split my workbook into lots of different worksheets?

RE: Workbooks & worksheets

Hi Jill

I don't understand what you are trying to achieve.

A workbook already has multiple worksheets so to increase the number you just add new worksheets.

However if you want to create a new workbook from every worksheet in a workbook you can do the following:


Sub CreateNewWorkbooks()

Dim NewBook As Workbook
Dim OldBook As Workbook
Dim MySheet As Worksheet

Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual


Set OldBook = Workbooks(ActiveWorkbook.Name)


For Each MySheet In OldBook.Worksheets
If MySheet.Visible = True Then
MySheet.Copy
ActiveWorkbook.SaveAs Filename:=OldBook.Path & "\" & MySheet.Name , FileFormat:=xlWorkbookNormal
ActiveWorkbook.Close
End If
Next

Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic

End Sub



Hope this helps

Carlos


Tue 16 Dec 2008: Automatically marked as resolved.

Excel tip:

Stop Formula Returning A "#DIV/0" Error

If a formula returns a #DIV/0 error message there is a way to avoid such results.

For example the formula =A1/B1 will return a #DIV/0 if B1 is empty or a zero.

If you protect your formulas with the ISERROR function, the formula will then look like this:

=IF(ISERROR(A1/B1),0,A1/B1)

In plain English: should the result of A1 divided by B1 be an error change the result to 0 else show the result of A1/B1.

View all Excel hints and tips

Connect with us:

0207 987 3777

Call for assistance

Request Callback

We will call you back

Server loaded in 0.09 secs.