+ Reply to Thread
Results 1 to 2 of 2

Looping through a column

  1. #1
    Registered User
    Join Date
    06-27-2005
    Posts
    1

    Looping through a column

    Hi

    Its been a while since I've used excel and have a fairly easy question. I'm trying to loop through a column (C). This column has either the word 'surplus' or 'deficit' in each cell. If the word is deficit I would like to multiply the value in the preceeding col (B) by -1.

    Any ideas greatly appreciated.

  2. #2
    Tom Ogilvy
    Guest

    Re: Looping through a column

    Sub AA()
    dim rng as Range, cell as Range
    set rng = Range(cells(1,"C"),cells(rows.count,"C").End(xlup))
    for each cell in rng
    if lcase(cell.value) = "deficit" then
    if isnumeric(cell.offset(0,-1)) then
    cell.offset(0,-1).value = cell.Offset(0,-1).value * (-1)
    end if
    end if
    Next
    End Sub

    --
    regards,
    Tom Ogilvy

    "hudson40" <[email protected]> wrote in
    message news:[email protected]...
    >
    > Hi
    >
    > Its been a while since I've used excel and have a fairly easy question.
    > I'm trying to loop through a column (C). This column has either the word
    > 'surplus' or 'deficit' in each cell. If the word is deficit I would like
    > to multiply the value in the preceeding col (B) by -1.
    >
    > Any ideas greatly appreciated.
    >
    >
    > --
    > hudson40
    > ------------------------------------------------------------------------
    > hudson40's Profile:

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




+ 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