View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Ken Ken is offline
external usenet poster
 
Posts: 207
Default Passing contents of a cell to a macro


Try range("A1").value if the path and filename are in the cell. If
only the filename is in the cell, you can probably use something like:

"C:\Documents and Settings\myusername\My Documents\" &
range('A1").value

This all presumes the filename is in cell A1 of the active sheet. You
could make the code more robust by naming the cell containing the
filename and referencing it by name rather than address. Something
like:

"C:\Documents and Settings\myusername\My Documents\" &
range('filename")

where filename is the name of the cell with the filename.

Good luck.

Ken
Norfolk, Va



On Sep 11, 12:36 pm, LivingIn32751
wrote:
I am creating a worksheet model which will be used repetitively. I have the
macro to start the new worksheet and pre-fill some of the cells. After
manually completing the rest of the information on the worksheet, I want to
run a macro which will save that worksheet to a filename that exists in one
of the cells.

Here is the SaveAs Filename macro:

ActiveWorkbook.SaveAs Filename:= _
"C:\Documents and Settings\myusername\My Documents\filename.xls",
FileFormat:=xlNormal _
, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
CreateBackup:=False

I want to be able to replace "filename" with the value in cell A5 for
instance.

How can I do this?

Thank you.
Learning In Florida