ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Copy Cells Q (https://www.excelbanter.com/excel-programming/419280-copy-cells-q.html)

Seanie

Copy Cells Q
 
How could I copy cells in a range but reverse its sign?

E.g To Copy Range A2:D2 to A1:D1
The value in A2= 15000
The value I wish then to see in A1 = -15000
Same for B2:D2 etc
There maybe <blanks in cells A2:D2 if so I would still want these
blank in A1:D1

Thanks


JE McGimpsey

Copy Cells Q
 
Are A1:D1 blank? If so, one way:

Copy A2:D2. Select A1:D1. Choose Edit/Paste Special, selecting the
Subtract radio button.


In article
,
Seanie wrote:

How could I copy cells in a range but reverse its sign?

E.g To Copy Range A2:D2 to A1:D1
The value in A2= 15000
The value I wish then to see in A1 = -15000
Same for B2:D2 etc
There maybe <blanks in cells A2:D2 if so I would still want these
blank in A1:D1

Thanks


Mike H

Copy Cells Q
 
Hi,

Put this in a1 and drag right to d1

=IF(A2<"",-A2,"")

Mike

"Seanie" wrote:

How could I copy cells in a range but reverse its sign?

E.g To Copy Range A2:D2 to A1:D1
The value in A2= 15000
The value I wish then to see in A1 = -15000
Same for B2:D2 etc
There maybe <blanks in cells A2:D2 if so I would still want these
blank in A1:D1

Thanks



Seanie

Copy Cells Q
 
Thanks guys, what I should have included is that I wanted to do this
via code, so from your suggestions, I recorded below

Sub CopyPreviousEvents()
Application.ScreenUpdating = False
Range("C59:AE60").Select
Range("C60").Activate
Selection.ClearContents
Range("C61:AE61").Select
Selection.Copy
Range("C60").Select
Selection.PasteSpecial Paste:=xlPasteValues,
Operation:=xlSubtract, _
SkipBlanks:=False, Transpose:=False
Range("C61:AE61").Select
Application.CutCopyMode = False
Selection.ClearContents
Range("C6").Select
End Sub



All times are GMT +1. The time now is 01:14 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com