+ Reply to Thread
Results 1 to 2 of 2

syntax question - cell references in VB code

  1. #1
    needyourhelp
    Guest

    syntax question - cell references in VB code

    Given the following code (found on this site..)

    With ActiveSheet.Range("B:B")
    Set FoundCell = .Find(what:="whatever", _
    after:=.Cells(.Cells.Count), _
    LookIn:=xlFormulas, LookAt:=xlPart, _
    SearchOrder:=xlByRows, SearchDirection:=xlNext, _
    MatchCase:=False)
    End With

    How do I tell VB to look in Cell H1 for the what:="whatever" ?

    ie. I want to use the value found in the Cell H1 not the text "whatever"

    I've tried every combination of H1, H1:H1, $H1, Range(H1), Range(H1:H1),
    Range("H1"),etc....

    All generate compile errors, syntax errors, or runtime errors....

    Forgive the simple question, but I'm not VB literate and I don't have a
    manual handy.


  2. #2
    JE McGimpsey
    Guest

    Re: syntax question - cell references in VB code

    One way:

    With ActiveSheet.Range("B:B")
    Set FoundCell = .Find(What:=ActiveSheet.Range("H1").Value, _
    After:=.Cells(.Cells.Count), _
    LookIn:=xlFormulas, _
    LookAt:=xlPart, _
    SearchOrder:=xlByRows, _
    SearchDirection:=xlNext, _
    MatchCase:=False)
    End With



    In article <[email protected]>,
    needyourhelp <[email protected]> wrote:

    > Given the following code (found on this site..)
    >
    > With ActiveSheet.Range("B:B")
    > Set FoundCell = .Find(what:="whatever", _
    > after:=.Cells(.Cells.Count), _
    > LookIn:=xlFormulas, LookAt:=xlPart, _
    > SearchOrder:=xlByRows, SearchDirection:=xlNext, _
    > MatchCase:=False)
    > End With
    >
    > How do I tell VB to look in Cell H1 for the what:="whatever" ?
    >
    > ie. I want to use the value found in the Cell H1 not the text "whatever"
    >
    > I've tried every combination of H1, H1:H1, $H1, Range(H1), Range(H1:H1),
    > Range("H1"),etc....
    >
    > All generate compile errors, syntax errors, or runtime errors....
    >
    > Forgive the simple question, but I'm not VB literate and I don't have a
    > manual handy.


+ 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