|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
VB EXCEL question / saving file
I have this code in a macro where it is to save the file automatically for me at work.
On the worksheet named Allen and the Cell B2 is a date. Code:
Sub SaveFile()
Dim myRange As Variant
Set myRange = Sheets("Allen").Range("B2")
Dim MyMonth, MyDay, Filename, SaveDate, NewFileName, usableDate
usableDate = myRange
MyMonth = Month(usableDate)
MyDay = Day(usableDate)
Filename = "AgentAux_"
SaveDate = MyMonth + MyDay
NewFileName = Filename + SaveDate
ChDir "P:\--WorkForce\Staffing"
ActiveWorkbook.SaveAs Filename:=NewFileName, FileFormat:=xlNormal
ActiveWindow.Close
MsgBox ("File saved in Staffing Folder")
End Sub
I always run into an error when I'm trying to set the variable MyMonth to the number of Month in the cell B2 For Example the file will be saved in that directory with the NewFilename = AgentAux_ddmm Any help will be appreciated |
|
#2
|
|||
|
|||
|
Hello roughneck82,
Using "&" instead of "+" for string concate. For example SaveDate = MyMonth + MyDay NewFileName = Filename + SaveDate Should be: SaveDate = MyMonth & MyDay NewFileName = Filename & SaveDate |
|
#3
|
|||
|
|||
|
Alright thanks a bunch I will try that
|
|
#4
|
|||
|
|||
|
MyMonth = Month(usableDate)
MyDay = Day(usableDate) That is the part the always has an error. The part where I'm trying to convert the Month and Day |
![]() |
| Viewing: ASP Free Forums > Programming > Visual Basic Programming > VB EXCEL question / saving file |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|