我有下面的代碼,它從 A1 單元格中獲取員工姓名并將其設定為檔案名的一部分。問題是excel表中的值寫為'first name last name'
無論如何我可以使用VBA將值格式化為“姓氏,名字”嗎?
Sub MyMacro()
Dim Employee As String
Dim FileN As String
Employee = Sheets("Sheet1").Range("A1").Value
FileN = Employee & "_appraisals_" & Format(Range("A2"), "yyyy.mmm")
ChDir "C:\Users\filepath\Desktop\PDFTest"
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=FileN, Quality:=xlQualityStandard _
, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:= _
False
End Sub
uj5u.com熱心網友回復:
就在這里。使用下面的代碼
Employee = Split(Employee, " ")(1) & " " & Split(Employee, " ")(0)
注意:我假設名字和姓氏是空格分隔的。
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/338668.html
