TheRoyAllen
New Member
- Joined
- Aug 3, 2011
- Messages
- 1
My boss recently asked me to modify an existing spreadsheet we use as a reporting on location at well sites. My experience with excel is mostly on the financial analysis side but I do know a little about VBA.
What I have is a button labeled "EXPORT FIELD DATA" and when you click the button it copies/exports the "Field Data" worksheet into a new workbook. I have been asked to modify this button to export the "Calculation", "Well Head Chart", and "Flow Rates Chart" worksheets along with the "Field Data" sheet. The button is set to run "Sub test3()" the code for which looks like...
Again I need it to export the 4 worksheets mentioned above into a single workbook. I know you could simply copy the four sheets over into a new workbook manually but that has been deemed "too difficult for the end user". Thanks for your help and let me know if I need to better clarify anything for you.
TheRoyAllen
What I have is a button labeled "EXPORT FIELD DATA" and when you click the button it copies/exports the "Field Data" worksheet into a new workbook. I have been asked to modify this button to export the "Calculation", "Well Head Chart", and "Flow Rates Chart" worksheets along with the "Field Data" sheet. The button is set to run "Sub test3()" the code for which looks like...
Code:
Sub test3()
'
' test3 Macro
' Macro recorded 8/29/2007 by Brad Myers
'
' Keyboard Shortcut: Ctrl+Shift+L
'
myfilename = Windows(1).Caption
Sheets("FIELD DATA").Select
Cells.Select
Selection.Copy
Workbooks.Add
newfilename = Windows(2).Caption
Cells.Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Cells.Select
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
'
With ActiveSheet.PageSetup
.PrintTitleRows = "$1:$14"
.PrintTitleColumns = "$A:$AE"
End With
ActiveSheet.PageSetup.PrintArea = "$A$1:$AE$856"
With ActiveSheet.PageSetup
.LeftHeader = ""
.CenterHeader = ""
.RightHeader = "Page &P"
.LeftFooter = ""
.CenterFooter = ""
.RightFooter = ""
.LeftMargin = Application.InchesToPoints(0)
.RightMargin = Application.InchesToPoints(0)
.TopMargin = Application.InchesToPoints(0)
.BottomMargin = Application.InchesToPoints(0)
.HeaderMargin = Application.InchesToPoints(0.25)
.FooterMargin = Application.InchesToPoints(0.25)
.PrintHeadings = False
.PrintGridlines = False
.PrintComments = xlPrintNoComments
.CenterHorizontally = True
.CenterVertically = True
.Orientation = xlLandscape
.Draft = False
.PaperSize = xlPaperLegal
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = 70
.PrintErrors = xlPrintErrorsDisplayed
End With
Range("A1").Select
ActiveWindow.Close
Range("A1").Select
Windows(myfilename).Activate
Application.CutCopyMode = False
Sheets("MENU").Select
End Sub
Again I need it to export the 4 worksheets mentioned above into a single workbook. I know you could simply copy the four sheets over into a new workbook manually but that has been deemed "too difficult for the end user". Thanks for your help and let me know if I need to better clarify anything for you.
TheRoyAllen