+ Reply to Thread
Results 1 to 3 of 3

Selecting offset cells

  1. #1
    Forum Contributor
    Join Date
    05-14-2006
    Posts
    104

    Selecting offset cells

    Just a quick enquiry if some one will
    thanks.

    i have a macro that checks the cell value and if the cell value = my value then i want it to delete the whole row
    However i just need a code that can either derive the row number from and active cell or select and delete a row depending on the active cell
    thanks

  2. #2
    kassie
    Guest

    RE: Selecting offset cells

    Do you want to delete the row in which the active cell is, or an offset row?

    "Zygan" wrote:

    >
    > Just a quick enquiry if some one will
    > thanks.
    >
    > i have a macro that checks the cell value and if the cell value = my
    > value then i want it to delete the whole row
    > However i just need a code that can either derive the row number from
    > and active cell or select and delete a row depending on the active
    > cell
    > thanks
    >
    >
    > --
    > Zygan
    > ------------------------------------------------------------------------
    > Zygan's Profile: http://www.excelforum.com/member.php...o&userid=34423
    > View this thread: http://www.excelforum.com/showthread...hreadid=548234
    >
    >


  3. #3
    Bob Phillips
    Guest

    Re: Selecting offset cells

    You do't need to check the active cell or select anything, all you need to
    do is loop through a range checking it. Also, when deleting, it is always
    best to work bottom-up.

    For example, this dchecks column A and deletes the row

    Sub Test()
    Dim iLastRow As Long
    Dim i As Long

    iLastRow = Cells(Rows.Count, "A").End(xlUp).Row
    For i = iLastRow To 1 Step -1
    If Cells(,"A").Value = "myValue" Then
    Rows(i).delete
    End If
    Next i

    End Sub



    --
    HTH

    Bob Phillips

    (replace somewhere in email address with gmail if mailing direct)

    "Zygan" <[email protected]> wrote in
    message news:[email protected]...
    >
    > Just a quick enquiry if some one will
    > thanks.
    >
    > i have a macro that checks the cell value and if the cell value = my
    > value then i want it to delete the whole row
    > However i just need a code that can either derive the row number from
    > and active cell or select and delete a row depending on the active
    > cell
    > thanks
    >
    >
    > --
    > Zygan
    > ------------------------------------------------------------------------
    > Zygan's Profile:

    http://www.excelforum.com/member.php...o&userid=34423
    > View this thread: http://www.excelforum.com/showthread...hreadid=548234
    >




+ 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