+ Reply to Thread
Results 1 to 2 of 2

setting search range from VBA

  1. #1
    Ian
    Guest

    setting search range from VBA

    I have the following to find the last cell used


    myrow = range("sheet1!S65536").END(xlup).row + 1



    I then need to search in cells based on the last cell found




    or each cell in range(z3:zx") 'x = myrow above

    if len(trim(cell.value)) < 1 then count = count + 1

    next cell

    range("a1").value = count


    How can i pass the myrow value so i can make it my range for search
    from z3 to z(myrow) ?

    thanks,


  2. #2
    Jim Thomlinson
    Guest

    RE: setting search range from VBA

    set a range equal to S3 to S?? and offset it by 7 columns. Then you can just
    move through the range...

    Dim myRange As Range
    Dim rng As Range

    With Sheets("Sheet1")
    Set myRange = .Range(.Range("S3"), _
    .Cells(Rows.Count,
    "S").End(xlUp)).Offset(0, 7)
    End With

    For Each rng In myRange
    'do your stuff here...
    MsgBox rng.Value
    Next rng

    --
    HTH...

    Jim Thomlinson


    "Ian" wrote:

    > I have the following to find the last cell used
    >
    >
    > myrow = range("sheet1!S65536").END(xlup).row + 1
    >
    >
    >
    > I then need to search in cells based on the last cell found
    >
    >
    >
    >
    > or each cell in range(z3:zx") 'x = myrow above
    >
    > if len(trim(cell.value)) < 1 then count = count + 1
    >
    > next cell
    >
    > range("a1").value = count
    >
    >
    > How can i pass the myrow value so i can make it my range for search
    > from z3 to z(myrow) ?
    >
    > thanks,
    >
    >


+ 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