View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
RB Smissaert RB Smissaert is offline
external usenet poster
 
Posts: 2,452
Default Use a Piece of Data for File Name

Is there a worksheet open when that code runs?

RBS


"AccessHelp" wrote in message
...
Hi RBS,

Thank you for the code. When I try it, I got an error "Run-time Error 6:
overflow".

Thanks.

"RB Smissaert" wrote:

Try this:

With Sheets(1)
FName1 = .Cells(1)
FName2 = .Cells(3)
End With


RBS



"AccessHelp" wrote in message
...
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.