My knowledge of VBA code is self-taught. I understand the basics but am having solving the following problem. I have VBA macro code that converts data in an excel worksheet saving it to a KML file and the macro works as coded. I would like to change line 12 of the following code to allow the user to select the workbook and worksheet containing the data and then continue with the conversion process.

Line 12 is: For Each cell In [Data!A2.A50001]

Respectfully,


************************************************************************************
Sub generateKML()

' GenerateKML Macro

' Set file details
Set filePath = [File_details!C2]

' Set document name
Set docName = [File_details!C3]

Open filePath For Output As #1

'Write header to file
outputText = [File_details!C5] & docName & [File_details!C6]
Print #1, outputText

'Start to loop through stations
For Each cell In [Data!A2.A50001]

pmName = cell.Offset(0, 0)
longitudeValue = cell.Offset(0, 1)
latitudeValue = cell.Offset(0, 2)
pmDescription = cell.Offset(0, 3)

If pmName = "" Then
Exit For
End If

'Create a placemark
outputText = [File_details!C8] & pmName & [File_details!C9] & longitudeValue & ", " & latitudeValue & [File_details!C10] & pmDescription & [File_details!C11]
Print #1, outputText

Next

'Write footer to file
outputText = [File_details!C13]
Print #1, outputText

Close #1

End Sub