+ Reply to Thread
Results 1 to 2 of 2

For Each loop; worksheets.range

Hybrid View

Excel_vba For Each loop;... 12-15-2009, 11:33 PM
davesexcel Re: For Each loop;... 12-15-2009, 11:48 PM
  1. #1
    Forum Contributor
    Join Date
    12-15-2009
    Location
    Herndon, VA
    MS-Off Ver
    Excel 2010
    Posts
    163

    Thumbs down For Each loop; worksheets.range

    This should be a very simple procedure. I can't tell what is wrong. In the end the words "It worked" should populate to the far right. Not sure if I am incorrectly using the "concat" object variable in the IF statement. I'm not receiving any error messages. The hour glass does show after I run the macro, so something is happening. Can anybody offer some insight?


    Sub populateSchI()
        
        Dim chargeNo As Range
        Dim concat As Range
        
        Set chargeNo = Worksheets("Schedule I").Range("A6")
        
        For Each concat In Worksheets("2008").Range("D:D")
            If concat.Value = chargeNo.Value Then
                concat.Offset(0, 7).Value = "It worked"
            End If
        Next concat
            
    
    End Sub
    Last edited by davesexcel; 12-15-2009 at 11:40 PM. Reason: Code tags are required when submitting VBA code, read the forum rules.

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,524

    Re: For Each loop; worksheets.range

    You should supply a sample workbook for somebody to work with

    I am assuming there could be a missing dim

        Dim r As Range
        Dim c As Range
        Set r = Range("G1", Range("G65536").End(xlUp))
        For Each c In r.Cells

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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