Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 213
Default Use a Piece of Data for File Name

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.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 411
Default Use a Piece of Data for File Name

Which operating system and version of Excel and are you using?

Dan Dungan

On Sep 26, 11:42 am, 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.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 213
Default Use a Piece of Data for File Name

Good morning Dan,

I am using Windows XP and Office 2003. Thanks.

"dan dungan" wrote:

Which operating system and version of Excel and are you using?

Dan Dungan

On Sep 26, 11:42 am, 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.




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default Use a Piece of Data for File Name

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.


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 213
Default Use a Piece of Data for File Name

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.





  #6   Report Post  
Posted to microsoft.public.excel.programming
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.




  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 213
Default Use a Piece of Data for File Name

Good morning RBS,

Yes, Workbook A and the new workbook will be opened. Basically, I have a
worksheet with a command button in Workbook A. When the user clicks on the
button, it will bring up a workbook containing the macro/code and will
execute the code. Once the code is executed, the macro workbook will close.
However, Workbook A will be opened at all time. The new workbook will only
open during the execution (during the move) and save it as the name that we
are trying to accomplish.

Thanks.

"RB Smissaert" wrote:

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.




  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default Use a Piece of Data for File Name

Yes, there is a workbook, but is there a sheet at the time that code runs?
Maybe you should post the relevant code.

RBS


"AccessHelp" wrote in message
...
Good morning RBS,

Yes, Workbook A and the new workbook will be opened. Basically, I have a
worksheet with a command button in Workbook A. When the user clicks on
the
button, it will bring up a workbook containing the macro/code and will
execute the code. Once the code is executed, the macro workbook will
close.
However, Workbook A will be opened at all time. The new workbook will
only
open during the execution (during the move) and save it as the name that
we
are trying to accomplish.

Thanks.

"RB Smissaert" wrote:

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.





  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default Use a Piece of Data for File Name

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.

  #10   Report Post  
Posted to microsoft.public.excel.programming
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.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Extracting single piece of data Louis Excel Discussion (Misc queries) 7 February 9th 06 12:28 AM
Extracting single piece of data Ron Coderre Excel Discussion (Misc queries) 0 February 8th 06 07:51 PM
Extracting single piece of data CLR Excel Discussion (Misc queries) 0 February 8th 06 07:46 PM
macro to import file (help with a piece of code) uriel78 Excel Programming 4 March 12th 05 08:36 AM
Run piece of code for each line of data Diane Alsing Excel Programming 5 February 16th 05 11:23 PM


All times are GMT +1. The time now is 02:40 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"