edwardzbrown
New Member
- Joined
- Jun 12, 2017
- Messages
- 20
I know this question has been answered before but I can't get it to work. I've seen it done a couple different ways and I try them all but I keep getting an error. I want a button that creates a relative path copy of my excel document and uses the values of two different cells as the file name. Value #1 is the last date of data entry. I have a cell with a formula that pulls the latest value in a column (is there any problem with using a cell that has a formula?). Value #2 is the name of the project. So the new file would be named date and project name. I actually want a #3rd value and that would just be the word "report". This is a tool we will send to our partners and they'll fill it out. That's why a static path can't work. It'll be used on all different computers. For simplicity sake it just needs to save someplace it can be found. The same folder the file is originally opened from is just fine. (I even seen a fancy 'IF-statement in case the file were opened from the internet and there is no relative path. A message box prompts the user to save first then generate a report.)
I'm not sure what I'm doing wrong. I never get it to even save. The following is the best example of what I'm trying to do that I've found. Thank you for all your help.
Sub Saving()
Dim part1 As String
Dim part2 As String
part1 = Range("C5").Value
part2 = Range("C8").Value
ActiveWorkbook.SaveAs Filename:= _
"C:\-docs\cmat\Desktop\pieteikumi" & part1 & " " & part2 & ".xlsm", FileFormat:= _
xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
End Sub
I'm not sure what I'm doing wrong. I never get it to even save. The following is the best example of what I'm trying to do that I've found. Thank you for all your help.
Sub Saving()
Dim part1 As String
Dim part2 As String
part1 = Range("C5").Value
part2 = Range("C8").Value
ActiveWorkbook.SaveAs Filename:= _
"C:\-docs\cmat\Desktop\pieteikumi" & part1 & " " & part2 & ".xlsm", FileFormat:= _
xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
End Sub