ok here goes...here is some code I put together for you for various
things you need.
If you have any question then let me know.
HINT:
Click on you userform and go look in the properties
Set the Show Modal to be false.
DO THIS FIRST!
-----------------------------------------------------------------------------
PRINT
Add a cmd button to your form
In the properties change the Caption to Print
and double click on it and paste this in:
Sheet1.PageSetup.PrintArea = "A1:T12"
Application.Dialogs(xlDialogPrint).Show
---------------------------------------------------------------------------
PRINT PREVIEW
You need the Userform to be set as ShowModal as False or you will get a
lock up
Add a cmd button to your form
In the properties change the Caption to Print Preview
and double click on it and paste this in:
Sheet1.PageSetup.PrintArea = "A1:T12"
Application.Dialogs(xlDialogPrintPreview).Show
-------------------------------------------------------------------------------------
SAVE AS
Add a cmd button to your form
In the properties change the Caption to Save As
and double click on it and paste this in:
Application.Dialogs(xlDialogSaveAs).Show
----------------------------------------------------------------------------------
NEXT SHEET
Firstly you need to remember that the code below Isent earlier is
written for sheet 1
To change this to work with the current sheet you need to change
sheet1.select to Activesheet.select
eg:
Private Sub CommandButton1_Click()
Activesheet.select
Range("A1").Value = TextBox1.Value
Range("A2").Value = TextBox2.Value
Range("A3").Value = Format(TextBox3.Value, "currency")
Range("A4").Value = Format(TextBox3.Value, "currency")
Range("A5").Value = Format(TextBox1.Value, "currency")
ActiveSheet.PageSetup.LeftFooter = TextBox4.Value
End Sub
.................................................. .....................
Ok...now to put the NEXT SHEET Button in.
Add a cmd button to your form
In the properties change the Caption to Next Sheet
and double click on it and paste this in:
If Sheets(ActiveSheet.Name).Index < Worksheets.Count Then
Sheets((Sheets(ActiveSheet.Name).Index) + 1).Activate
End If
ActiveSheet.Select
----------------------------------------------------------------------------------------------------------------
OPEN FORM FROM MENU
TO add an item to the menu bar under tools to open the userform1
I called the description I added to the Tools menu was "My Excel Form"
( you can change this to what every you like.)
In
vb editor double click This workbook and paste the code below:
Private Sub Workbook_Open()
Dim item As CommandBarControl
On Error Resume Next
Application.CommandBars(1).Controls("Tools").Contr ols("MY EXCEL
FORM").Delete
Set item = Application.CommandBars(1).Controls("Tools").Contr ols.Add
item.Caption = "&MY EXCEL FORM"
item.BeginGroup = True
item.OnAction = "MYEXCELSHOW"
item.BeginGroup = True
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
On Error Resume Next
Application.CommandBars(1).Controls("Tools").Contr ols("&MY EXCEL
FORM").Delete
End Sub
.................................................. ..................................
Then you will need to insert a module( eg: module 1) and paste the
code below:
Sub MYEXCELSHOW()
UserForm1.Show
End Sub
--------------------------------------------------------------------------------------------------------------------
AUTO OPEN FORM
To have the form come up automatically when you open the xls then
paste the following in a module (eg: module 1)
Sub auto_open()
Call MYEXCELSHOW
End Sub
-----------------------------------------------------------------------------------------------------------------
CLOSE FORM
Add a cmd button to your form
In the properties change the Caption to Close
and double click on it and paste this in:
Unload me