Syntax error

praveenlal

New Member
Joined
Oct 27, 2021
Messages
34
Office Version
  1. 2016
Platform
  1. Windows
Hi Friends, Getting syntax error in line 3. Can anyone help

ActiveCell.FormulaR1C1 = "='[Book1.xlsm]Sheet1'!R2C2"
ActiveWorkbook.SaveAs Filename:="='[Book1.xlsm]Sheet1'!R2C5"
, FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False (getting syntax error in this line)
Range("A1").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ActiveWorkbook.Save
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
You need a line continuation character:

Rich (BB code):
ActiveWorkbook.SaveAs Filename:="='[Book1.xlsm]Sheet1'!R2C5" _
, FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
 
Upvote 0
Thanks Eric, but now I'm getting error in both lines :)

ActiveWorkbook.SaveAs Filename:="='[Book1.xlsm]Sheet1'!R2C5" _
, FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
You need a line continuation character:

Rich (BB code):
ActiveWorkbook.SaveAs Filename:="='[Book1.xlsm]Sheet1'!R2C5" _
, FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
 
Upvote 0
That worked for me, that was a screen capture of my editor. Try putting them together as one line:

VBA Code:
ActiveWorkbook.SaveAs Filename:="='[Book1.xlsm]Sheet1'!R2C5", FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False

I'm also leery about the file name. It looks like you're trying to get the name from a cell, but the way you have it coded, it looks like you're trying to name it the cell address.
 
Upvote 0

Forum statistics

Threads
1,215,365
Messages
6,124,511
Members
449,166
Latest member
hokjock

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