標題:
[發問]
怎樣用VBA將分頁內的不同列資料更新後,自動填入到不同分頁的某一列?
[打印本頁]
作者:
leondavinci727
時間:
2013-3-27 10:02
標題:
怎樣用VBA將分頁內的不同列資料更新後,自動填入到不同分頁的某一列?
請問能做到當我資料頁更新資料後,所指定的列資料就寫入個別分頁,且從上一筆被紀錄的資料依序往下記錄下去嗎?
懇請賜教,謝謝~
[attach]14461[/attach]
作者:
Hsieh
時間:
2013-3-27 10:36
回復
1#
leondavinci727
Sub activateMacro()
Dim dic As Object, ky, A As Range, r%
Set dic = CreateObject("Scripting.Dictionary")
Dim com_no As String
com_no = Worksheets("類D").Range("$K$3").Value
With ActiveSheet.QueryTables("類D")
.Connection = "URL;http://www.twse.com.tw/ch/trading/exchange/BFIAMU/genpage/Report201303/" & com_no & "_F3_1_5.php?chk_date=102/03/26"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlOverwriteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = False
.RefreshPeriod = 0
.WebFormatting = xlWebFormattingNone
.WebTables = "8"
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
r = 35
Do Until Cells(r, 1) = ""
dic(Cells(r, 1).Value) = Range(Cells(r + 1, 1), Cells(r + 1, 1).End(xlToRight)).Value
r = r + 2
Loop
For Each ky In dic.keys
With Sheets(ky)
Set A = .Cells(.Rows.Count, 1).End(xlUp).Offset(1, 0)
A.Resize(, UBound(dic(ky), 2)) = dic(ky)
End With
Next
End Sub
複製代碼
作者:
leondavinci727
時間:
2013-3-27 11:40
回復
2#
Hsieh
:D 非常感謝 Hsieh 超級版主的幫忙! 執行完全無誤,謝謝您那麼快速的伸出援手,小弟有很多看不懂的地方要在好好研究,非常感謝~
歡迎光臨 麻辣家族討論版版 (http://forum.twbts.com/)