Board logo

標題: [發問] 資料庫抓取資料問題請教 [打印本頁]

作者: rouber590324    時間: 2019-9-16 16:48     標題: 資料庫抓取資料問題請教

DEAR ALL 大大
  1如下最終RRA3100分段執行RRA1  RRA2 RRA3 後結果OK
  2但小弟只會分 RRA1  RRA2 RRA3 分寫程式.
  3請教如何將 RRA1  RRA2 RRA3 寫成同一程式中
  4煩不吝賜教   THANKS*10000

Sub RRA3100()
Application.Run "RRA1"
Application.Run "RRA2"
Application.Run "RRA3"
End Sub

Sub RRA1()
Sheet2.[A2:A65536].ClearContents
X = Sheet2.[A65536].End(xlUp).Row
    For B = 2 To 101
     Sheet2.Cells(X, 1) = Sheet1.Cells(2, 1) & Sheet1.Cells(1, B) & " " & Sheet1.Cells(2, B)
        X = X + 1
    Next
End Sub

Sub RRA2()
X = Sheet2.[A65536].End(xlUp).Row
    For B = 2 To 101
     Sheet2.Cells(X + 1, 1) = Sheet1.Cells(3, 1) & Sheet1.Cells(1, B) & " " & Sheet1.Cells(3, B)
        X = X + 1
    Next
End Sub

Sub RRA3()
X = Sheet2.[A65536].End(xlUp).Row
    For B = 2 To 101
     Sheet2.Cells(X + 1, 1) = Sheet1.Cells(4, 1) & Sheet1.Cells(1, B) & " " & Sheet1.Cells(4, B)
        X = X + 1
    Next
End Sub
作者: rouber590324    時間: 2019-9-17 10:17

如下終於試出來拉 感恩

Sub 抓取分析100乘100資料2()
X = Sheet2.[A65536].End(xlUp).Row
K = Sheet1.[A65536].End(xlUp).Row
'MsgBox K
M = Sheet1.Cells(K, Columns.Count).End(xlToLeft).Column()
'MsgBox M
  For A = 2 To K
    For B = 2 To M

     Sheet2.Cells(X + 1, 1) = Sheet1.Cells(A, 1) & Sheet1.Cells(1, B) & " " & Sheet1.Cells(A, B)
        X = X + 1
     Next
    Next
End Sub




歡迎光臨 麻辣家族討論版版 (http://forum.twbts.com/)