View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.programming
AccessHelp AccessHelp is offline
external usenet poster
 
Posts: 213
Default Use a Piece of Data for File Name

Good morning eliano,

Thanks for the code.

When I tried your code, I got an error:

"'Test.xls' cannot be accessed. The file may be read-only, or you may be
trying to access a read-only location. Or, the server the document is
stored on may not be responding."

If you don't mind, please read my today's response to RB Smissaert above for
the process of my code.

Thanks.

"eliano" wrote:

HI.
Try:

Public Sub prova()
Dim newname As String
With Sheets(1)
newname = .Cells(1) & .Cells(3)
End With
MsgBox newname
End Sub

Regards
Eliano
"AccessHelp" wrote:

Hi,

I have a worksheet 1 in a workbook A. I have a code to move the worksheet 1
into a new workbook. I want to name the new workbook using the two pieces of
data from cells A1 and C1 from Workbook A. For example, cells A1 and C1 have
ABC and 123 in Workbook A, respective. Then the new workbook name will be
"ABC123.xls".

How should I reference Cells A1 and C1 in my code in order to name the new
file?

I tried using:

FName1 = Worksheets("1").Range("A1")
FName2 = Worksheets("1").Range("C1")

When I run the code, I got an error message that file "ABC123.xls" can not
be accessed. It didn't save the file, and the new workbook is left open.

Please help. Thanks.