+ Reply to Thread
Results 1 to 3 of 3

Using cell value in VBA sub

  1. #1
    Lupus
    Guest

    Using cell value in VBA sub

    I'm using the following sub

    Sub FindRow()
    Dim rngFound As Range


    Set rngFound = Range("A:A").Cells.Find(What:="test", _
    LookIn:=xlFormulas, _
    LookAt:=xlPart, _
    MatchCase:=False)
    If rngFound Is Nothing Then
    MsgBox "Sorry ""test"" was not found"
    Else
    rngFound.EntireRow.Select
    End If
    End Sub

    My problem is that if I excange Test with a1 - wanting to look the value in
    cell a1 I always get the first blank a-cell. I have removed the "". What is
    wrong?

    Lupus

  2. #2
    Harald Staff
    Guest

    Re: Using cell value in VBA sub

    Hi again

    Set rngFound = Range("A2:A65536").Cells.Find(What:=Range("A1").value, _

    But it may find itself; A1 is in the search area...

    HTH. Best wishes Harald

    "Lupus" <Lupus@discussions.microsoft.com> skrev i melding
    news:6B3B2614-533B-4754-BCF2-1C79C5261A28@microsoft.com...
    > I'm using the following sub
    >
    > Sub FindRow()
    > Dim rngFound As Range
    >
    >
    > Set rngFound = Range("A:A").Cells.Find(What:="test", _
    > LookIn:=xlFormulas, _
    > LookAt:=xlPart, _
    > MatchCase:=False)
    > If rngFound Is Nothing Then
    > MsgBox "Sorry ""test"" was not found"
    > Else
    > rngFound.EntireRow.Select
    > End If
    > End Sub
    >
    > My problem is that if I excange Test with a1 - wanting to look the value

    in
    > cell a1 I always get the first blank a-cell. I have removed the "". What

    is
    > wrong?
    >
    > Lupus




  3. #3
    Óã¸É
    Guest

    Re: Using cell value in VBA sub

    Sub FindRow()
    Dim rngFound As Range


    Set rngFound = Range("A:A").Cells.Find(What:=Range("a1"), _
    LookIn:=xlFormulas, _
    LookAt:=xlPart, _
    MatchCase:=False)
    If rngFound Is Nothing Then
    MsgBox "Sorry ""test"" was not found"
    Else
    rngFound.EntireRow.Select
    End If
    End Sub
    "Lupus" <Lupus@discussions.microsoft.com> дÈëÓʼþ
    news:6B3B2614-533B-4754-BCF2-1C79C5261A28@microsoft.com...
    > I'm using the following sub
    >
    > Sub FindRow()
    > Dim rngFound As Range
    >
    >
    > Set rngFound = Range("A:A").Cells.Find(What:="test", _
    > LookIn:=xlFormulas, _
    > LookAt:=xlPart, _
    > MatchCase:=False)
    > If rngFound Is Nothing Then
    > MsgBox "Sorry ""test"" was not found"
    > Else
    > rngFound.EntireRow.Select
    > End If
    > End Sub
    >
    > My problem is that if I excange Test with a1 - wanting to look the value

    in
    > cell a1 I always get the first blank a-cell. I have removed the "". What

    is
    > wrong?
    >
    > Lupus




+ 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