Hi All,
I am trying to simplify a code on Excel VBA. Im a beginner in VBA and recorded a macro however im trying to learn from it but VBA adds a lot of useless stuff to it im told. Could any simplify the below code? All im doing is coding it in VBA so it goes to a website, extra an Exchange rata data table into excel, copy and pasts the 2 Exchange rates I want into specific cells and then delete the imported data. Appreciate the help.
Sub AnotherOneTestRates()
'
' AnotherOneTestRates Macro
'
'
Sheets("Data Reports").Select
With ActiveSheet.QueryTables.Add(Connection:="URL;http://www.x-rates.com", _
Destination:=Range("$AB$32"))
.Name = "www.x-rates"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlAllTables
.WebFormatting = xlWebFormattingNone
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
ActiveWindow.SmallScroll Down:=3
Range("AC36").Select
Selection.Copy
Range("W4").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("AD36").Select
Application.CutCopyMode = False
Selection.Copy
Range("W5").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Range("AC32:AG37").Select
Selection.ClearContents
Range("W10").Select
End Sub
I am trying to simplify a code on Excel VBA. Im a beginner in VBA and recorded a macro however im trying to learn from it but VBA adds a lot of useless stuff to it im told. Could any simplify the below code? All im doing is coding it in VBA so it goes to a website, extra an Exchange rata data table into excel, copy and pasts the 2 Exchange rates I want into specific cells and then delete the imported data. Appreciate the help.
Sub AnotherOneTestRates()
'
' AnotherOneTestRates Macro
'
'
Sheets("Data Reports").Select
With ActiveSheet.QueryTables.Add(Connection:="URL;http://www.x-rates.com", _
Destination:=Range("$AB$32"))
.Name = "www.x-rates"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlAllTables
.WebFormatting = xlWebFormattingNone
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
ActiveWindow.SmallScroll Down:=3
Range("AC36").Select
Selection.Copy
Range("W4").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("AD36").Select
Application.CutCopyMode = False
Selection.Copy
Range("W5").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Range("AC32:AG37").Select
Selection.ClearContents
Range("W10").Select
End Sub