Board logo

標題: [發問] 多SHEET工作表資料匯整問題請教 [打印本頁]

作者: rouber590324    時間: 2020-10-19 13:32     標題: 多SHEET工作表資料匯整問題請教

DEAR ALL大大
1.如下為目前我書寫抓取多sheet資料至 sheet2之方式
2.因工作表sheet4  5 6 7 8 9  10........有多個
2.1如何不須一個工作表寫一程式.
3.煩不吝賜教    thanks*10000


Sub TATAL()
Application.Run "TATAL4"
Application.Run "TATAL5"
Application.Run "TATAL6"
End Sub

Sub TATAL4()
Sheet2.[A2:A65536].ClearContents
X = Sheet4.[B65536].End(xlUp).Row
Y = Sheet2.[A65536].End(xlUp).Row
For M = 2 To X
If Not (Sheet4.Cells(M, 2) = "" Or Sheet4.Cells(M, 2) = " ") Then
  Sheet2.Cells(Y + 1, 1) = Sheet4.Cells(M, 2)
    Y = Y + 1
  End If
  Next
End Sub

Sub TATAL5()
X = Sheet5.[B65536].End(xlUp).Row
Y = Sheet2.[A65536].End(xlUp).Row
For M = 2 To X
If Not (Sheet5.Cells(M, 2) = "" Or Sheet5.Cells(M, 2) = " ") Then
  Sheet2.Cells(Y + 1, 1) = Sheet5.Cells(M, 2)
    Y = Y + 1
  End If
  Next
End Sub

Sub TATAL6()
X = Sheet6.[B65536].End(xlUp).Row
Y = Sheet2.[A65536].End(xlUp).Row
For M = 2 To X
If Not (Sheet6.Cells(M, 2) = "" Or Sheet6.Cells(M, 2) = " ") Then
  Sheet2.Cells(Y + 1, 1) = Sheet6.Cells(M, 2)
    Y = Y + 1
  End If
  Next
End Sub
作者: jcchiang    時間: 2020-10-19 14:06

回復 1# rouber590324

試試看
Sub ex()
Sheets(2).[A2:A65536].ClearContents
Y = Sheets(2).[A65536].End(xlUp).Row
For R = 4 To Worksheets.Count     
   X = Sheets(R).[B65536].End(xlUp).Row
   For M = 2 To X
     If Not (Sheets(R).Cells(M, 2) = "" Or Sheets(R).Cells(M, 2) = " ") Then
       Sheets(2).Cells(Y + 1, 1) = Sheets(R).Cells(M, 2)
       Y = Y + 1
     End If
  Next
Next
End Sub
作者: rouber590324    時間: 2020-10-19 16:56

DEAR  jcchiang  SIR
100%符合需求  thanks*10000




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