Good Afternoon All,
I have Excel 2013, Windows 7 Professional... I currently have the code below, and would like to change the line just above "End Sub" that contains "ActiveWorkbook.Sheets("Sheet1").range("D3") = dateString" so that it puts in the current date into that cell. I just started playing with VBA today, and am trying to get this accomplished so I can say I successfully created my first report that uses a VBA script... Can anyone help me out?
I have Excel 2013, Windows 7 Professional... I currently have the code below, and would like to change the line just above "End Sub" that contains "ActiveWorkbook.Sheets("Sheet1").range("D3") = dateString" so that it puts in the current date into that cell. I just started playing with VBA today, and am trying to get this accomplished so I can say I successfully created my first report that uses a VBA script... Can anyone help me out?
Code:
Sub RetrieveData()
'Initialize variables
Dim i As Integer
Dim URL As String
Dim sheet As String
Dim range As String
Dim dateString As String
URL = "http://***.**********.*****/RetrieveDataTable?OpenAgent&dataTable=Customers&userid=***-********&password=********&download=FALSE&includeEmptyTag=FALSE&dereference=TEXT&fieldList=emailOne_customerProfile~nameFirst_customerProfile~nameLast_customerProfile&selectionCriteria=contEnrollmentOtherEducation_customerProfile~EQ_LS~WouldYouLikeToKnowMore-yes&selectionCriteria=dateOfIntake_customerProfile~GE_LS~"
dateString = Application.InputBox("Enter a date in YYYYMMDD format")
URL = URL & dateString
'Enter the name of the sheet to insert the data into
sheet = "Sheet1"
'Enter where in that sheet you would like the data to go
range = "A1"
'Remove any previous XML maps (used for schema generation)
For i = ActiveWorkbook.XmlMaps.Count To 1 Step -1
ActiveWorkbook.XmlMaps(i).Delete
Next
'Clear the sheet so data can be inserted into it.
'NOTE: This CLEARS ALL the content in the sheet specified above
'Comment this out if you do not wish to clear all the contents on the sheet
'BUT if you are trying to insert data into cells that already have
'content in them, you will get an error message
ActiveWorkbook.Sheets(sheet).Cells.Clear
'Import XML data file, creating a new XML mapping.
ActiveWorkbook.XmlImport URL:=URL, ImportMap:=Nothing, Overwrite:=True, Destination:=ActiveWorkbook.Sheets(sheet).range(range)
'Remove the connection that was just created in the workbook
ActiveWorkbook.Connections("RetrieveDataTable").Delete
[I][B]ActiveWorkbook.Sheets("Sheet1").range("D3") = dateString[/B][/I]
End Sub