XML file with First and Last Name



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

XML file with First and Last NameFirst Name,Last Name

Top Contributor Asked on February 5, 2017 in VBA: Programming.
Add Comment
1 Answer(s)
Best answer


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.


Expert Answered on February 8, 2017.

thank you it works perfectly

on February 9, 2017.
Add Comment
  • Found this useful?

    Please share using the share button above.

    If you found the answer is best answer for your question, Please mark as 'best answer' by clicking on the right tick mark icon at the left side of the answer.

    Found the answer useful and wants to credit the user, then vote the answer (vote up).

  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.