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
|