View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.misc
rita rita is offline
external usenet poster
 
Posts: 64
Default Copy of VB code to new spreadsheet

Thank you Roger. I found this code under Workbook in ThisWorkbook:
Private Sub Workbook_Open()
End Sub
I also found this code under Worksheet (I changed all 3 of them):
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
End Sub
I tried deactivating all of them, but it still opens up the old file.

I also used this main spreadsheet as basis to create a new, different
spreadsheet and the same thing is happening when I use the macro in the new
spreadsheet, the old one is opening up.

Thanks for any help you can give me. I am so frustrated!



"Roger Govier" wrote:

Hi Rita

There is nothing in the code you show which would cause that to happen.
There must be other macros in the workbook, either in a sub called
Auto_open or in an Open event in the ThisWorkbook module.

Your existing code could be simplified to

Sub PRINT3SAVE()

Range("U45").Copy
Range("W4").PasteSpecial xlPasteValues
Range("U46").Copy
Range("W39").PasteSpecial xlPasteValues
Application.CutCopyMode = False

ActiveWindow.SelectedSheets.PrintOut Copies:=3
Application.Dialogs(xlDialogSaveAs).Show

End Sub
--
Regards
Roger Govier

Rita wrote:
I am saving a spreadsheet with a new name. When I run the macro in the new
spreadsheet, it automatically opens up the old spreadsheet as well as doing
the macro. It doesn't transfer me to the new spreadsheet, it just opens it
up. This is driving me crazy! Here is my VB code, if it helps. Thanks to
anyone who can help me.

Sub PRINT3SAVE()
'Sub date1()
'
' date1 Macro
' Saves date created
'
Range("U45").Select
Selection.Copy
Range("W4").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("U46").Select
Selection.Copy
Range("W39").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False

' PRINT3SAVE Macro
' Prints 3 copies and saves file
'
ActiveWindow.SelectedSheets.PrintOut Copies:=3
Application.Dialogs(xlDialogSaveAs).Show

End Sub

.