I'm trying to set up a loop to pull data from multiple cells in multiple worksheets
- cshortt
- Thread is marked as Resolved.
-
-
-
Re: I'm trying to set up a loop to pull data from multiple cells in multiple workshee
Is the table on your actual file named something other than "Table1"?
-
Re: I'm trying to set up a loop to pull data from multiple cells in multiple workshee
No, it is named Table1 according to the name box to the left of the formula bar.
One thing I did change was in the (NAME) field, I made all of the "G" numbers 3 digit numbers. For example G-01 is the NAME of the worksheet, G001 is the (NAME) of the worksheet. I did this because the numbers of all of the "G" go from 1 - 110. Without all of the (NAME) fields being 3 digit numbers, the order of the sheets in the list is not correct. Maybe that has something to do with it? -
Re: I'm trying to set up a loop to pull data from multiple cells in multiple workshee
Try changing that macro to:
Code
Display MoreSub btnUpdate_Click() Dim ws As Worksheet, lRow As Long Application.ScreenUpdating = 0 With A_LBVN For Each ws In Sheets If Len(ws.Name) < 5 Then lRow = IIf(lRow = 0, 7, lRow + 1) .Cells(lRow, 2).Resize(, 13) = Array _ (ws.[b6], ws.[b30], ws.[b18], ws.[b9], ws.[b12], ws.[b15], ws.[b21], _ ws.[b33], ws.[b27], ws.[j30], ws.[f24], ws.[h24], ws.[d18]) End If Next With .ListObjects(1).Range .Sort .Columns(1), , , , , , , 1 End With .[n2] = Date End With MsgBox "Database successfully updated", , "Database Update" End Sub
That should work no matter how the Table is named. -
Re: I'm trying to set up a loop to pull data from multiple cells in multiple workshee
KjBox! YOU WIN THE PRIZE!!! Works perfectly!! YAHOO!!!!
THANK YOU THANK YOU!!!!
You have made my weekend!!! -
Re: I'm trying to set up a loop to pull data from multiple cells in multiple workshee
You're welcome.
Have you had a look at the file attached to Trebor's post (Post #19) to see how use of formulas works?
-
Re: I'm trying to set up a loop to pull data from multiple cells in multiple workshee
I have not. But I will. I am anxious to learn more about VBA now.
-
Re: I'm trying to set up a loop to pull data from multiple cells in multiple workshee
QuoteI have not. But I will. I am anxious to learn more about VBA now.
Just bare in mind that formulas are always more efficient than code.
Well done to KjBox for the nifty solution provided
Robert
Participate now!
Don’t have an account yet? Register yourself now and be a part of our community!