这是做你想做的。
它不会变得漂亮,但这就是excel在“从网上获取”时的工作原理。
您需要打开VBA编辑器并在项目窗口中点击Sheet1。
然后粘贴下面的代码。
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Target.Worksheet.Range("A1")) Is Nothing Then
------------------------------------
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://airnav.com/airport/" & Range("A1").Value, Destination:=Range("$B$1")) ' <--- This line must be as I wrote it.
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = False
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlOverwriteCells '<--- And this one.
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlSpecifiedTables
.WebFormatting = xlWebFormattingNone
.WebTables = "6,7,8,9,32,33,34,35,36,37"
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
----------------------------------
End If
End Sub
将该文件另存为宏活动工作簿,然后在A1中输入机场并按Enter键。
就像我说的......这不是漂亮...
我已上载这里的文件:https://expirebox.com/download/dfbae2fbc4410bbaf64d068443ac84bf.html
我从来没有使用本网站之前,不知道它是如何工作的。
我明白如何做到这一点,但我想知道是否有办法让excel查看一个单元格并使用它来搜索正确的数据。因此,如果我决定更改初始单元格中的数据,则会自动更改第二个单元格中的数据。 – abite
@abite查看更新 –
我可以,但这将涉及手动从千万机场提取数据。哪种失败了自动化的目的:P我很感激你的帮助! – abite