+ Reply to Thread
Results 1 to 3 of 3

help with afind replace and change of data amount from minus to postive and viceversa

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    09-06-2011
    Location
    northern ireland
    MS-Off Ver
    Excel 365
    Posts
    180

    help with afind replace and change of data amount from minus to postive and viceversa

    Hi

    I attach a test file, how can I find component "Unpaid Leave" for any employee with this pay component to then change the minus value to a plus and a plus value to a minus ?

    I have done a before and after as to what I need my macro to do to help - in the test file attached.

    In excel I would do a ctrl and find "Unpaid Leave" then an if statement : if (cell<0, cell * -1, active cell value) - but I don't know how to do this in vba ?

    Thanks in advance for your help.
    Leanne
    Attached Files Attached Files

  2. #2
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: help with afind replace and change of data amount from minus to postive and vicev

    Hi,

    Try this:

    Sub test()
    
    Dim rngLoopRange As Range
    For Each rngLoopRange In Range("C2:C" & Range("C" & Rows.Count).End(xlUp).Row)
        If UCase(rngLoopRange.Value) = "UNPAID LEAVE" Then
            With rngLoopRange.Offset(0, 2)
                .Value = .Value * -1
            End With
        End If
    Next rngLoopRange
    
    End Sub
    Dom
    "May the fleas of a thousand camels infest the crotch of the person who screws up your day and may their arms be too short to scratch..."

    Use code tags when posting your VBA code: [code] Your code here [/code]

    Remember, saying thanks only takes a second or two. Click the little star to give some Rep if you think an answer deserves it.

  3. #3
    Forum Contributor
    Join Date
    09-06-2011
    Location
    northern ireland
    MS-Off Ver
    Excel 365
    Posts
    180

    Re: help with afind replace and change of data amount from minus to postive and vicev

    Thank you very much - that worked perfectly !

+ 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