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

Both answers I have received LOOK good, but they don't seem to be working.
I'm getting "expression expected" errors. I suspect the concatenation
character. Perhaps I need more quotes or parentheses, but try as I may, I'm
not getting past the errors. I've eliminated the spaces between the
concatenated operands to no avail. I've added parens to no avail. Should I
be using single of double quotes? 'Tis a puzzlement!
--
Learning In Florida


"Ken" wrote:


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