Excel VBA Macro: Attempting to write something to pull data from various spreadsheets into one (harder circumstances inside)

StackOverflow https://stackoverflow.com/questions/17328066

  •  01-06-2022
  •  | 
  •  

Domanda

So I am trying to pull information from one column in every sheet I have in my workbook. There are currently 506 sheets. Each one has a different number of rows and each sheet has its own unique name. Each sheet's data that I want starts at row 8, and it is in column J. I am trying to print all of these to the C column in a page I have called test which is in the same workbook but is not counted in the 506 sheets that I mentioned earlier. This is what I've written so far:

Sub Test()
Columns(3).Insert
For i = 1 To i = 506
    Do While Worksheets(i).Cells(i + 7, 10) <> Null
        Worksheets("test").Cells(i, 3) = Worksheets(i).Cells(i + 7, 10)
    Loop
Next i

End Sub

I just started with this today but I have experience with a lot of other languages so my syntax may be somewhat off too.

Thanks in advance for any advice/hints that any of you genius people can offer

È stato utile?

Soluzione

Your description was diferent from your code so I guessed... I think this is close to what you want...

Sub Test()

     Dim WS_Count As Integer
     Dim I As Integer

     WS_Count = ActiveWorkbook.Worksheets.Count


     For I = 1 To WS_Count

        ' ONLY IF it is not TEST
        If ActiveWorkbook.Worksheets(I).Name <> "TEST" Then
            ActiveWorkbook.Worksheets("TEST").Cells(1, 3) = ActiveWorkbook.Worksheets(I).Cells(7, 10)

        End If

     Next I

  End Sub
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top