Results 1 to 6 of 6

Retrieve data from specific sheets

Threaded View

  1. #1
    Registered User
    Join Date
    01-19-2011
    Location
    Romania
    MS-Off Ver
    Excel 2003
    Posts
    7

    Retrieve data from specific sheets

    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:

    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
    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.
    Last edited by danj; 01-19-2011 at 03:53 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1