VBA to pull data from various sheets with sheet na

2019-09-15 04:36发布

I have a workbook which consist of a main sheet "Monthly collection reeport" and few sheets with dates. I need to pull the data from all sheets (only total column C14-D14) to main sheet "Monthly" (C4-D14 ) one below other first column with sheet names in column B1-B13 respectively.

enter image description here

2条回答
来,给爷笑一个
2楼-- · 2019-09-15 05:08

So the final codes will be

Sub xxxxx() Dim j As Integer x = Sheets.Count ' count no of sheets For j = 4 To x + 2 Range("B" & j) = Worksheets(j - 2).Name ' main sheet must be the first, run code from main sheet Next End Sub

查看更多
贪生不怕死
3楼-- · 2019-09-15 05:26

Adjust this to your needs:

Sub xxxxx()
Dim j As Integer
x = Sheets.Count ' count no of sheets
For j = 1 To x - 1 
Range("a" & j) = Worksheets(j + 1).Name ' main sheet must be the first, run code from main sheet
Next
End Sub      
查看更多
登录 后发表回答