Concatenate & Date

G

General Specific

I am trying to create a macro that saves a spreadsheet to a name based
on data in a few cells.

For example, if I have Date and ProjectName in two cells, I want the
macro to save the worksheet as DateProjectName.csv.

I tried to Concatenate these values into one cell. From there I was
goint to use the following the Save As that value using:

Public Sub SaveAsA1()
ThisFile = Range("A1").Value
ActiveWorkbook.SaveAs Filename:=ThisFile
End Sub


Concatenate changes the date to a string returning 38936ProjectName.
What is going on here?

Anyone have a better way to do this?
 
D

Dave Peterson

ThisFile = format(range("a2").value, "yyyymmdd") & Range("A1").Value

Remember that Windows doesn't like /'s in file names.
 
D

Dave F

Well, if you were using CONCATENATE in the workbook, your function should
look like this: =CONCATENATE(DATE(2006,9,1),"ProjectName") -->
9/1/2006ProjectName

I imagine it's similar in VBA.

Dave
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top