Hello!
This is my fist post here and I'm rather new to Excel, so I'll probably cause a lot of laughs. Here is the matter:
I have a file with 50+ sheets, of which 45 are named nr1, nr2, nr3... nr(still growing). I need to collect all the data in the first column of each sheet that starts with "nrX" and add it into the Xth column of a different sheet (1st column of 1st sheet to 1st column, 1st column of 2nd sheet into 2nd column etc.). The data in those cells is text. The problem is that my lame script only reads the first sheet. Here is what I have so far:
I added the msgbox only to see which sheet actually gets read, if you're wondering why it's there. I can't seem to make it work past the first sheet.![]()
Sub Test() Dim sh As Worksheet, flg As Boolean For Each sh In Worksheets If sh.Name Like "nr*" Then flg = True: Exit For Next If flg = True Then MsgBox sh.Name sh.Range(sh.Range("A2"), sh.Range("A250").End(xlUp)).Copy Sheets("sumar").Cells(2, xllastcolumn + 1).End(xlUp)(2).PasteSpecial Paste:=xlValues End If End Sub
Bookmarks