View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
tim tim is offline
external usenet poster
 
Posts: 105
Default Save As - using data from two cells

Very new

I think I'm getting closer. I created the control button
and pasted the code in as;
Private Sub CommandButton1_Click()
Dim FName1, FName2, Fullname
FName1 = Range("AU1").Value
If FName1 = "" Then End
FName2 = Range("B1").Value
If FName2 = "" Then End
Fullname = FName1 & FName2
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Fullname, FileFormat _
:=xlNormal, CreateBackup:=False
End Sub

But I get error message Compile error named argument not
found "Private Sub...." is highlighted in yellow and
FileFormat_:= is highlight in blue.

I appreciate the help
Tim
and

-----Original Message-----
Sorry Tim, my mistake, there was a syntax error in that

lineof code,
this is how it should look:

ActiveWorkbook.SaveAs Fullname, FileFormat_:=xlNormal,
CreateBackup:=False

'Createbackup:=false' should be on the same line as
Activeworkbook.blahblahblah. You can put this code into a

button by
creating it from yourcontrol toolbox (don't want to be

patronizing, but
I don't know how new you mean when you say you're new).

Then just
double click the button and stick your code in there.

Alternatively if
you want to do this when 'save as' is clicked you can

stick the code
into the BeforeSave event of the Activeworkbook. So your

code should
look like this:

Dim FName1 As String, FName2 As String, Fullname As String
FName1 = Range("AU2").Value
FName2 = Range("J4").Value
Fullname = FName1 & FName2
ActiveWorkbook.SaveAs Fullname, FileFormat_:=xlNormal,
CreateBackup:=False


If that still doesn't work, I'll post a workbook up here

with the code
in it.

Cheers


---
Message posted from http://www.ExcelForum.com/

.