Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Reference a cell as the file name

Thanks again for the help. I got it to work out that way, I made it so both
sheets had the desired filename in the same address, and also managed to
create a shortcut button and put it on the tool bar. This will be very
helpful for my dad.

Thank you,
Cory

"promiscuousman" wrote:

Haha, I didn't even notice that actually. The address of the cell is
actually different between sheet 1 and sheet 2, but that can easily be
changed since the first 15 rows are so are just filler, and I can add some
more to one of them and make them narrower so they still fit on one page and
the cell number will be the same. I'll give this a try now, and reassign the
button i've created to this macro instead.
Thank you for your help,
Cory

"Norman Jones" wrote:

Hi Cory,

Firstly. apologies for the unintententional attempt to change your gender!

If I understand your intentions, and assuming that the address of the cell
of interest is constant on each sheet, try replacing the sheet reference
with the ActiveSheet property:

'=============
Public Sub Tester001()
Dim rng As Range

Set rng = ActiveSheet.Range("B20")

ActiveWorkbook.SaveAs _
Filename:=rng.Value & ".xls", _
FileFormat:=xlWorkbookNormal

End Sub
'<<=============

---
Regards,
Norman



"promiscuousman" wrote in message
...
This is the macro I eneded up creating
Public Sub Tester001()
Dim rng As Range

Set rng = Sheets("Sheet1").Range("B20") '<<==== CHANGE

ActiveWorkbook.Saveas _
Filename:=rng.Value & ".xls", _
FileFormat:=xlWorkbookNormal

End Sub
B20 is the cell I wish to save as, in sheet one, but if they use sheet two
instead it's a different cell (they will never use both sheets in the
workbook at the same time) is there a way to make it recognize the active
sheet, and base the cell number off of the sheet name?
Admittedly I don't know much about this code stuff, I took an intro class
to
it, and I've got an idea how it works, declaring variables and such, and I
can kind of follow a code somebody else wrote, and see what it's doing,
but I
won't be able to write my own, yet.
Thanks for the help,
Cory
"Norman Jones" wrote:

Hi PromiscuousWoman,

Try something like:

'=============
Public Sub Tester001()
Dim rng As Range

Set rng = Sheets("Sheet1").Range("A1") '<<==== CHANGE

ActiveWorkbook.Savas _
Filename:=rng.Value & ".xls", _
FileFormat:=xlWorkbookNormal

End Sub
'<<=============


Change the sheet name and the range to accord with your needs.

---
Regards,
Norman



"promiscuousman" wrote in
message
...
I want to do something very similar to this. I made a template for my
dad
with 3 different sheets. He will be using only one of these sheets
each
time
the template is opened, and saving it as a number entered in one of the
cells. How would I create a macro that will put the cell value as the
file
name?

Thanks,
Cory







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
Reference only part of a cell edeaston Excel Discussion (Misc queries) 7 February 17th 10 09:59 PM
Use worksheet name in one cell as part of reference in other cells Steamer Excel Discussion (Misc queries) 5 June 30th 09 03:25 AM
Reference to a Variable Part of a Cell Hilvert Scheper Excel Worksheet Functions 7 September 3rd 08 11:40 AM
Using a cell reference as part of a link Missy Excel Discussion (Misc queries) 3 February 3rd 06 08:48 PM
worksheet tab name as part of a cell reference cwee Excel Worksheet Functions 4 February 10th 05 04:37 PM


All times are GMT +1. The time now is 11:18 AM.

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"