PasteSpecial value*-1

ndendrinos

Well-known Member
Joined
Jan 17, 2003
Messages
1,694
I'm trying through a VBA IF code to do this:

……..A…….........B…….
54...............................
55..................49……..
56.................-50……..
57…….......……...-1………..

to that:

……..A…….........B…….
54...............................
55..................49……..
56.................-49……..
57…….......……....0………..

[B55] is a linked cell
[B56] is a number (not typed by hand but introduced through code)
[B57] is the sum of [B55:B56]

How can I get this result based on this logic:
For each negative cell in Row 57
Go up two rows/same column & copy value
Come down one row/same column and paste special Values *-1

(it is the business of the "*-1" that I need most help with if possible that is)

Many thanks
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Something like this:
Code:
Sub test()
Dim r As Range
Dim v As Variant

For Each r In Selection


    If Left(r.Formula, 4) = "=SUM" Then Cells(r.Row - 1, r.Column) = -Cells(r.Row - 2, r.Column).Value
    
Next r
End Sub
 
Upvote 0
great solution njimack sure beats my original recording of:
Code:
Range("E58").Activate
    ActiveCell.FormulaR1C1 = "=R[-3]C*-1"
    Range("E58").Activate
    Selection.Cut
    Range("E56").Activate
    ActiveSheet.Paste

Many thanks
 
Upvote 0

Forum statistics

Threads
1,224,618
Messages
6,179,919
Members
452,949
Latest member
beartooth91

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top