VBA code to create new workbook and move 3 sheets into it

rob_sheeds

Board Regular
Joined
Dec 9, 2010
Messages
57
Hi,
I am looking for help with some code to
  • Move 3 sheets (all with formulas) into a new workbook.
  • Workbook needs to then be saved as "DSR_DDMMYYYY".xlsx
  • Press save again (this will refresh the formulas which use an addin to query a database)
  • Select all sheets
  • Select all
  • Copy, Paste Values
  • Press save again
  • Initiate another macro to email book
Anyone willing to give this a go?
Cheers:)
Rob
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Hi,
I am looking for help with some code to
  • Move 3 sheets (all with formulas) into a new workbook.
  • Workbook needs to then be saved as "DSR_DDMMYYYY".xlsx
  • Press save again (this will refresh the formulas which use an addin to query a database)
  • Select all sheets
  • Select all
  • Copy, Paste Values
  • Press save again
  • Initiate another macro to email book
Anyone willing to give this a go?
Cheers:)
Rob

How many sheets does the old workbook have and what are there names? Do you already have an email macro? Are you using Lotus Notes or Outlook?
 
Upvote 0
Only 3 sheets visible but all 6 sheets need to move across as they are parameter sheets holding lists etc, but the report may grow. I can read VBA and make minor changes so I can change when needed if the code is forgiving.
I have attached a copy and the macro is sitting in there but it keeps pointing to an earlier version of the macro i think.
Maybe if you can make it point to the one in the book too? Not too good with that.
Cheers!!!!!:biggrin:
If you have an email I can send the book?..Cant attach.
Sheet 1 = Daily Sales Report
Sheet 2 = Open Orders
Sheet 3 = SOGS
Sheet 4 = Lists
Sheet 5 = ListsA
Sheet 6 = AtlasParameters
(Last 3 sheets need hiding)
Macro is Module 1 = "Sub Mail_workbook_Outlook_1()" Hope this helps.
Appreciate your time too.
Thanks
 
Upvote 0
Only 3 sheets visible but all 6 sheets need to move across as they are parameter sheets holding lists etc, but the report may grow. I can read VBA and make minor changes so I can change when needed if the code is forgiving.
I have attached a copy and the macro is sitting in there but it keeps pointing to an earlier version of the macro i think.
Maybe if you can make it point to the one in the book too? Not too good with that.
Cheers!!!!!:biggrin:
If you have an email I can send the book?..Cant attach.
Sheet 1 = Daily Sales Report
Sheet 2 = Open Orders
Sheet 3 = SOGS
Sheet 4 = Lists
Sheet 5 = ListsA
Sheet 6 = AtlasParameters
(Last 3 sheets need hiding)
Macro is Module 1 = "Sub Mail_workbook_Outlook_1()" Hope this helps.
Appreciate your time too.
Thanks

I don't have Outlook, so I can't offer anything for that, but I was going to suggest something like this:

Code:
Sub robsheeds()

Dim i As Long

    Workbooks.Open Filename:= _
        "C:\YOUR PATH\OLDWORKBOOK.xls"
    ActiveWorkbook.SaveAs Filename:="C:YOUR PATH\DSR_" & Format(Date, "DDMMYYYY") & ".xls", _
        FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
        ReadOnlyRecommended:=False, CreateBackup:=False
        
With ActiveWorkbook

    For i = 1 To 6
    
        Sheets("Sheet" & i).Cells.Value = Sheets("Sheet" & i).Cells.Value
        
    Next i
    
End With

Call Outlook Macro

End Sub
 
Upvote 0
Only 3 sheets visible but all 6 sheets need to move across as they are parameter sheets holding lists etc, but the report may grow. I can read VBA and make minor changes so I can change when needed if the code is forgiving.
I have attached a copy and the macro is sitting in there but it keeps pointing to an earlier version of the macro i think.
Maybe if you can make it point to the one in the book too? Not too good with that.
Cheers!!!!!:biggrin:
If you have an email I can send the book?..Cant attach.
Sheet 1 = Daily Sales Report
Sheet 2 = Open Orders
Sheet 3 = SOGS
Sheet 4 = Lists
Sheet 5 = ListsA
Sheet 6 = AtlasParameters
(Last 3 sheets need hiding)
Macro is Module 1 = "Sub Mail_workbook_Outlook_1()" Hope this helps.
Appreciate your time too.

Thanks
Hi Rob

can you send me these to my mail
thanks

prasad@lange-me.com
 
Upvote 0
Works except for this
Sheets("Sheet" & i).Cells.Value = Sheets("Sheet" & i).Cells.Value
error says; Runtime error '9'
Subscript out of range.

Here is the code I am using
Sub robsheeds()
Dim i As Long
Workbooks.Open Filename:= _
"C:\Users\rsheedy\Desktop\Daily Sales\Daily Sales Report NEW Open Sales Orders - Copy.xlsm"
ActiveWorkbook.SaveAs Filename:="R:\Reports\Archive\Daily Sales Reports\May 2011\DSR_" & Format(Date, "DDMMYYYY") & ".xlsm", _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False

With ActiveWorkbook
For i = 1 To 6

Sheets("Sheet" & i).Cells.Value = Sheets("Sheet" & i).Cells.Value

Next i

End With
Mail_workbook_Outlook_1
End Sub

Note that I have used .xlsm so would this be affecting the columns/rows ranges from .xls to .xlsx?
Or do I have to insert the sheet names into that line?
Cheers
 
Upvote 0

Forum statistics

Threads
1,214,788
Messages
6,121,603
Members
449,038
Latest member
Arbind kumar

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top