+ Reply to Thread
Results 1 to 3 of 3

Houston, We've Had a Problem

  1. #1
    Registered User
    Join Date
    08-01-2006
    Posts
    38

    Cool Houston, We've Had a Problem

    I'm getting a problem with this line of code, something about global referense or something like that.......

    Set RngColD = Range("D1", Range("D" & Rows.Count).End(xlUp))

    the complete code is this....


    Dim RngColD As Range
    Dim i As Range
    Dim Info As String
    Set RngColD = Range("D1", Range("D" & Rows.Count).End(xlUp))
    Info = ""
    For Each i In RngColD
    If i.Value = Range("A517").Value Then
    If Info = "" Then
    Info = i.Offset(, 20).Value
    Else
    Info = Info & "," & i.Offset(, 20).Value
    End If
    End If
    Next i
    Range("G517") = Info
    Info = ""

    End Sub

  2. #2
    Jim Thomlinson
    Guest

    RE: Houston, We've Had a Problem

    I see nothing distinctly wrong with what you have. Try being a little more
    explicit in your referencing to the sheet perhaps. Something like this...

    Dim RngColD As Range
    Dim i As Range
    Dim Info As String
    Dim wks As Worksheet

    set wks = ActiveSheet
    with wks
    Set RngColD = .Range(.Range("D1"), .Cells(Rows.Count, "D").End(xlUp))
    end with

    Info = ""
    For Each i In RngColD
    If i.Value = Range("A517").Value Then
    If Info = "" Then
    Info = i.Offset(, 20).Value
    Else
    Info = Info & "," & i.Offset(, 20).Value
    End If
    End If
    Next i
    Range("G517") = Info
    Info = ""

    End Sub

    --
    HTH...

    Jim Thomlinson


    "John21" wrote:

    >
    > I'm getting a problem with this line of code, something about global
    > referense or something like that.......
    >
    > Set RngColD = Range("D1", Range("D" & Rows.Count).End(xlUp))
    >
    > the complete code is this....
    >
    >
    > Dim RngColD As Range
    > Dim i As Range
    > Dim Info As String
    > Set RngColD = Range("D1", Range("D" & Rows.Count).End(xlUp))
    > Info = ""
    > For Each i In RngColD
    > If i.Value = Range("A517").Value Then
    > If Info = "" Then
    > Info = i.Offset(, 20).Value
    > Else
    > Info = Info & "," & i.Offset(, 20).Value
    > End If
    > End If
    > Next i
    > Range("G517") = Info
    > Info = ""
    >
    > End Sub
    >
    >
    > --
    > John21
    > ------------------------------------------------------------------------
    > John21's Profile: http://www.excelforum.com/member.php...o&userid=36983
    > View this thread: http://www.excelforum.com/showthread...hreadid=569407
    >
    >


  3. #3
    Jim Thomlinson
    Guest

    RE: Houston, We've Had a Problem

    I see nothing distinctly wrong with what you have. Try being a little more
    explicit in your referencing to the sheet perhaps. Something like this...

    Dim RngColD As Range
    Dim i As Range
    Dim Info As String
    Dim wks As Worksheet

    set wks = ActiveSheet
    with wks
    Set RngColD = .Range(.Range("D1"), .Cells(Rows.Count, "D").End(xlUp))
    end with

    Info = ""
    For Each i In RngColD
    If i.Value = Range("A517").Value Then
    If Info = "" Then
    Info = i.Offset(, 20).Value
    Else
    Info = Info & "," & i.Offset(, 20).Value
    End If
    End If
    Next i
    Range("G517") = Info
    Info = ""

    End Sub

    --
    HTH...

    Jim Thomlinson


    "John21" wrote:

    >
    > I'm getting a problem with this line of code, something about global
    > referense or something like that.......
    >
    > Set RngColD = Range("D1", Range("D" & Rows.Count).End(xlUp))
    >
    > the complete code is this....
    >
    >
    > Dim RngColD As Range
    > Dim i As Range
    > Dim Info As String
    > Set RngColD = Range("D1", Range("D" & Rows.Count).End(xlUp))
    > Info = ""
    > For Each i In RngColD
    > If i.Value = Range("A517").Value Then
    > If Info = "" Then
    > Info = i.Offset(, 20).Value
    > Else
    > Info = Info & "," & i.Offset(, 20).Value
    > End If
    > End If
    > Next i
    > Range("G517") = Info
    > Info = ""
    >
    > End Sub
    >
    >
    > --
    > John21
    > ------------------------------------------------------------------------
    > John21's Profile: http://www.excelforum.com/member.php...o&userid=36983
    > View this thread: http://www.excelforum.com/showthread...hreadid=569407
    >
    >


+ Reply to Thread

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