#1
|
|||
|
|||
How to save Excel file by field name as filename
For example I need to save a Excel doc by Costumer Number (example; David Hass) and Request Number (example: 001-17) so when I click on button Save by CN & RN, my Excel file should be saved on Desktop by name David Hass 001-17. Please see attachment
|
#2
|
||||
|
||||
No attachments visible...
__________________
Did you know you can thank someone who helped you? Click on the tiny scale in the right upper hand corner of your helper's post |
#3
|
|||
|
|||
I noticed that both the Customer Number and Request Number are in Sheet1 in Cells(4, 2) = B4 and in Cells(2, 5) = E2
If you change that, you need to change these references also. Code:
Sub Maybe() Dim wb1 As Workbook, wbName As String, j As Long Application.ScreenUpdating = False Set wb1 = ThisWorkbook wbName = wb1.Sheets("Sheet1").Cells(4, 2).Value & " " & wb1.Sheets("Sheet1").Cells(2, 5).Value ActiveWorkbook.SaveAs Filename:=CreateObject("WScript.Shell").Specialfolders("Desktop") & "\" & wbName, _ FileFormat:=xlOpenXMLWorkbookMacroEnabled ActiveWorkbook.Close Application.ScreenUpdating = True End Sub |
#4
|
|||
|
|||
Dear jolivanes,
Attached please find my excel file maybe this helps you understand what I really want. Anyway I appreciate your help. Kind regards |
#5
|
|||
|
|||
Code:
Sub Maybe() Dim wb1 As Workbook, wbName As String, j As Long Application.ScreenUpdating = False Set wb1 = ThisWorkbook wbName = wb1.Sheets("Sheet1").Cells(4, 3).Value & " " & wb1.Sheets("Sheet1").Cells(5, 3).Value ActiveWorkbook.SaveAs Filename:=CreateObject("WScript.Shell").Specialfolders("Desktop") & "\" & wbName, _ FileFormat:=xlOpenXMLWorkbookMacroEnabled ActiveWorkbook.Close Application.ScreenUpdating = True End Sub |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
How can I save a Word Document as a PDF file with a merged field filename? | kp2009 | Word VBA | 5 | 08-27-2015 11:45 PM |
Excel connot open file (filename) xlsx | dengeorge6 | Excel | 0 | 12-12-2014 01:36 AM |
Save Filename based on Text Field | madcar86 | Word VBA | 8 | 10-19-2014 12:53 AM |
Auto update Filename field | Oliver Beirne | Word VBA | 4 | 10-19-2012 03:33 AM |
Save Filename using Document Text | Knawl | Word | 11 | 10-10-2011 03:00 AM |