I want the output file to have both first and last name, currently it is picking only one of them when I am using this code, how do i fix it:-
Private Sub CommandButton1_Click() Dim iCntr Dim strFile_Path As String Dim Filename As String 'Change cell reference accordingly Filename = Sheets("Input_Auto").Range("C10") strFile_Path = "C:\Temp\" & Filename & Format(Now(), "dd-MMM-yyyy h-m-s") & ".xml" Open strFile_Path For Output As #1 For iCntr = 1 To 1110 Print #1, Sheets("CCH_Import_Equity_Auto").Range("D" & iCntr) Next iCntr Close #1 End Sub
Here is the solution to refer First name from one cell and Last name from another cell.
You can replace your statement (Filename = Sheets(“Input_Auto”).Range(“C10”)) with the following VBA statement.
Filename = Sheets("Input_Auto").Range("C10") _ & Sheets("Input_Auto").Range("C11")
Hope it clarifies your query.