PDA

View Full Version : formatting numbers extracted with a web querry



adygelber
06-29-2014, 11:49 PM
Hello,

I have a simple macro which extracts EUR rates from a website but the number format as appeares in Excel is a disaster.

I am attaching the file as maybe someone can help me to format the rates accordingly.

Thank you!

Bob Phillips
06-30-2014, 02:34 AM
Sub Macro1()

With ActiveSheet

.UsedRange.ClearContents

With .QueryTables.Add(Connection:="URL;http://www.x-rates.com/table/?from=EUR&amount=1.00", Destination:=Range("$A$1"))
.Name = "EUR Rates"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlSpecifiedTables
.WebFormatting = xlWebFormattingNone
.WebTables = "2"
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With

.Columns("B").TextToColumns Destination:=Range("B1"), _
DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=False, _
Tab:=True, Semicolon:=False, Comma:=False, Space:=False, Other:=False, _
FieldInfo:=Array(1, 1), _
TrailingMinusNumbers:=True

.Columns("B").NumberFormat = "General"

.Range(.Range("C1"), .Range("C" & .Rows.Count).End(xlUp)).ClearContents
End With
End Sub