Thank you so much Dave, I really don't think I would have ever gotten
all of this together without your help.
Thanks to your last comments I had a lightbulb go off, and eventhough I
did not use your solution directly, it mad me realize something I was
missing.
Ultimately I ended up delaying the definition of the QNum varible until
after the template file was saved. Hey Presto Bango! :) It worked like a
charm, and now the file saves exactly as it should everytime.
Here is the code I ended up using:
Code:
--------------------
Option Explicit
Private Sub CommandButton1_Click()
'
'Declares Variables of the file name for saved as function
Dim QNum As String
Dim CNam As String
Dim CrDt As String
Dim VNum As String
'
'Defines the variable names from Quote Form
CNam = Range("N19").Text
CrDt = Format(Now, "mmddyy")
VNum = Range("AA10").Text
'
'Changes the Quote Number to Increase by 1
Range("W10").Value = Range("W10").Value + 1
Range("W10").Copy
Range("W10").PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Application.CutCopyMode = False
'
'Saves the New Quote in the template
ActiveWorkbook.SaveAs "X:\_FEE SCHEDULE & QUOTE MODULE\Quote Module 1.1"
'
'Defines the QNum varible to the new quote number after the template is saved
'to insure they are saved with the same number
QNum = Range("W10").Text
'
'Saves the New Quote as a unique file
ActiveWorkbook.SaveAs "X:\_FEE SCHEDULE & QUOTE MODULE\" & QNum & "-" & CNam & "-" & CrDt & "-" & " Ver" & VNum
End Sub
--------------------
So, here is the last problem. Is there a way to make it so that a user
can not reuse the button. (ie Once the file has been saved with a
unique name, it can not have the quote number changed.) Any ideas? Is
this even possible?
Thanks again in advance, I hope you had a glorious new year!
Amber D.
Dave Peterson Wrote:
You could add one to the cell first, then pick it up:
with range("w10")
.value = .value + 1
QNum = .Text
end with
or you could add one after you pick it up:
QNum = "MOB" & format(range("w10").value + 1, "0000000")
Amber_D_Laws wrote:
Yes, you did use the right variable names, and your solution worked.
However, I just noticed it is saving the file with the number prior
to
the change. Any ideas how to fix?
Thanks again! and have a Happy New Year!
Dave Patterson wrote:
Instead of:
QNum = Range("W10").Value
you could use:
QNum = Range("W10").Text
.text will return the formatted number.
Or if W10 actually contained 62, you could do the formatting
yourself
in code:
QNum = "MOB" & format(range("w10").value, "0000000")
===
Did I use the right variable names? I was kind of confused.
Amber_D_Laws wrote:
Ok. That took care of the run time / type mismatch, but now I have
a
slightly different issue.
The first varible is the quote number, which if formated in the
cell
to
appear as "MOB0000062", of course the value of the cell is only
62.
How do I get the file name to return the text and not the value?
Sorry to be so picky about it.
Thanks for finding my problem for the type mismatch, that alone
was
a
lifesaver!
--
Amber_D_Laws
------------------------------------------------------------------------
Amber_D_Laws's Profile:
http://www.excelforum.com/member.php...o&userid=30012
View this thread:
http://www.excelforum.com/showthread...hreadid=497045
--
Dave Peterson
--
Amber_D_Laws
------------------------------------------------------------------------
Amber_D_Laws's Profile:
http://www.excelforum.com/member.php...o&userid=30012
View this thread:
http://www.excelforum.com/showthread...hreadid=497045
--
Dave Peterson
--
Amber_D_Laws
------------------------------------------------------------------------
Amber_D_Laws's Profile:
http://www.excelforum.com/member.php...o&userid=30012
View this thread:
http://www.excelforum.com/showthread...hreadid=497045