Results 1 to 2 of 2

Loop through worksheet

Threaded View

  1. #1
    Registered User
    Join Date
    11-24-2015
    Location
    Mexico
    MS-Off Ver
    2010
    Posts
    3

    Loop through worksheet

    I have this code

    Dim ws As Worksheet
    Set e = Sheets("Search")
    Dim d
    Dim j
    d = 3

    For Each ws In ThisWorkbook.Worksheets
    j = 2
    Do Until IsEmpty(ws.Range("B" & j))
    If ws.Range("B" & j) = e.Range("B2").Text Then
    If ws.Range("C" & j) = e.Range("D2").Text Then
    d = d + 1
    e.Rows(d).Value = ws.Rows(j).Value
    e.Range("h" & d) = ws.Name
    End If
    End If
    j = j + 1
    Loop
    Next ws

    I want this macro to search in each worksheet in certains columns for words and if that word is in that column i want it to copy to the worksheet Search. For some reason after searching in the third worksheet it stops.

    In my workbook there are 11 worksheets where it should search plus the Search sheet. Can someone help me to find the error?
    Last edited by arlettelee94; 11-26-2015 at 03:37 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Loop to find data in a worksheet and copy into a different worksheet.
    By emily_k8_lewis in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-29-2013, 06:44 AM
  2. Replies: 2
    Last Post: 10-14-2013, 05:37 PM
  3. VBA Loop for a folder of all the files, Loop all the worksheet in each workbook
    By nanjingwoodworking in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-07-2013, 07:20 PM
  4. [SOLVED] Loop formula on one worksheet until empty cell on another worksheet
    By Natstin in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-27-2013, 11:16 PM
  5. worksheet object as string - loop statement in worksheet index
    By ag273n in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-20-2013, 12:27 PM
  6. [SOLVED] VBA loop to copy a worksheet a number of times, assign name each time based on loop number
    By TBG in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-29-2012, 10:54 PM
  7. Worksheet loop won't loop
    By L. Howard Kittle in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-16-2006, 09:00 PM

Tags for this Thread

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