"Compile error" Syntoax Error" Please help

misterno

Board Regular
Joined
Mar 16, 2009
Messages
78
This code stops at the bolded line

The error says "Compile error" Syntoax Error"

Please help

Thanks

----------------------------


Sub SaveDailySummary()
Dim mydate As Date
Dim myhalfday As String
mydate = Sheets("TheICE").Range("B2").Value
myhalfday = Sheets("Daily Summary").Range("J2").Value

Sheets("Daily Summary").Activate
Sheets("Daily Summary").Copy
Cells.Select
Selection.Copy
Cells.Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False

ActiveWorkbook.SaveAs Filename:= _
"M:\dept\SLNGNA\Gas LPM\Structuring\Price Curves\Commercial Curves\GSGNA Commercial Curves Indication\Daily sheets\" & "GSGNA Commercial Curves Indication_" & VBA.Format(mydate, "MMDDYYYY") & "_" & myhalfday & ".xlsx", _
FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
ActiveWindow.Close


Sheets(Array("TheICE", "Foward Cube", "ICE raw data_previous")).Select

ChDir _
"M:\dept\SLNGNA\Gas LPM\Structuring\Price Curves\Commercial Curves\GSGNA Commercial Curves Indication\Daily PDF"
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
"M:\dept\SLNGNA\Gas LPM\Structuring\Price Curves\Commercial Curves\GSGNA Commercial Curves Indication\Daily PDF\" & "GSGNA Commercial Curves Indication_" & VBA.Format(mydate, "MMDDYYYY") & "_" & myhalfday & ".pdf"
, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
:=False, OpenAfterPublish:=False
Sheets("Daily Summary").Select
Sheets("TheICE").Select
End Sub
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Change this:
"MMDDYYYY") & "_" & myhalfday & ".pdf"
to this:
"MMDDYYYY") & "_" & myhalfday & ".pdf" _
 
Upvote 0
Change this:
"MMDDYYYY") & "_" & myhalfday & ".pdf"
to this:
"MMDDYYYY") & "_" & myhalfday & ".pdf" _

I did that and now the beow bolded line gives the same error

Please help
------------------
Sub SaveDailySummary()
Dim mydate As Date
Dim myhalfday As String
mydate = Sheets("TheICE").Range("B2").Value
myhalfday = Sheets("Daily Summary").Range("J2").Value

Sheets("Daily Summary").Activate
Sheets("Daily Summary").Copy
Cells.Select
Selection.Copy
Cells.Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False

ActiveWorkbook.SaveAs Filename:= _
"M:\dept\SLNGNA\Gas LPM\Structuring\Price Curves\Commercial Curves\GSGNA Commercial Curves Indication\Daily sheets\" & "GSGNA Commercial Curves Indication_" & <ACRONYM title="visual basic for applications">VBA</ACRONYM>.Format(mydate, "MMDDYYYY") & "_" & myhalfday & ".xlsx", _
FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
ActiveWindow.Close


Sheets(Array("TheICE", "Foward Cube", "ICE raw data_previous")).Select

ChDir _
"M:\dept\SLNGNA\Gas LPM\Structuring\Price Curves\Commercial Curves\GSGNA Commercial Curves Indication\Daily PDF"
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
"M:\dept\SLNGNA\Gas LPM\Structuring\Price Curves\Commercial Curves\GSGNA Commercial Curves Indication\Daily PDF\" & "GSGNA Commercial Curves Indication_" & <ACRONYM title="visual basic for applications">VBA</ACRONYM>.Format(mydate, "MMDDYYYY") & "_" & myhalfday & ".pdf"_
, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
:=False, OpenAfterPublish:=False
Sheets("Daily Summary").Select
Sheets("TheICE").Select
End Sub
 
Upvote 0
You need to post using code tags so line continuations can be discerned. You need a space followed by an underscore to mark every line continuation.
 
Upvote 0
You need to post using code tags so line continuations can be discerned. You need a space followed by an underscore to mark every line continuation.


I am sorry I don't know how to post using code tags. Can you please show me?
 
Upvote 0
Before the first line of your code enter the word code surrounded with square brackets [] and after the last line of your code enter /code surrounded with square brackets.
 
Upvote 0
Ok thanks

Here you go

It still stops at the bolded line

Please help


Rich (BB code):
Sub SaveDailySummary()
Dim mydate As Date
Dim myhalfday As String
mydate = Sheets("TheICE").Range("B2").Value
myhalfday = Sheets("Daily Summary").Range("J2").Value

Sheets("Daily Summary").Activate
Sheets("Daily Summary").Copy
Cells.Select
Selection.Copy
Cells.Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False

ActiveWorkbook.SaveAs Filename:= _
"M:\dept\SLNGNA\Gas LPM\Structuring\Price Curves\Commercial Curves\GSGNA Commercial Curves Indication\Daily sheets\" & "GSGNA Commercial Curves Indication_" & VBA.Format(mydate, "MMDDYYYY") & "_" & myhalfday & ".xlsx", _
FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
ActiveWindow.Close


Sheets(Array("TheICE", "Foward Cube", "ICE raw data_previous")).Select

ChDir _
"M:\dept\SLNGNA\Gas LPM\Structuring\Price Curves\Commercial Curves\GSGNA Commercial Curves Indication\Daily PDF"
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
"M:\dept\SLNGNA\Gas LPM\Structuring\Price Curves\Commercial Curves\GSGNA Commercial Curves Indication\Daily PDF\" & "GSGNA Commercial Curves Indication_" & VBA.Format(mydate, "MMDDYYYY") & "_" & myhalfday & ".pdf"_
, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas
:=False, OpenAfterPublish:=False
Sheets("Daily Summary").Select
Sheets("TheICE").Select
End Sub
 
Last edited:
Upvote 0
You need to put the word "code" (w/o the quotes) inside those square brackets.
 
Upvote 0
Code:
myhalfday & ".pdf"_

A line continuation is a SPACE followed by an underscore:

Code:
myhalfday & ".pdf" _
 
Upvote 0

Forum statistics

Threads
1,216,084
Messages
6,128,730
Members
449,465
Latest member
TAKLAM

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