P
Paul
I have a routine that reverses the sign of a list of data. This particularly
useful when entering a list of items and discovering that they're the wrong
way round.
However, it relies on cell A1 being available to create the -1 in the
clipboard.
The drawback with this is that it doesn't work on protected sheets (unless
A1 is unprotected, of course).
Is there a better way of putting -1 into the clipboard ?
Sub Paste_Minus()
' Check that a file is open before attempting to run the procedure
If IsFileOpen() = False Then Exit Sub
' cFormula is the formula contained in cell A1
cFormula = Range("A1").Formula
Range("A1").Value = -1
Range("A1").Copy
Selection.PasteSpecial Paste:=xlValues, Operation:=xlMultiply,
SkipBlanks _
:=False, Transpose:=False
' Return the original formula in A1
Range("A1").Formula = cFormula
End Sub
useful when entering a list of items and discovering that they're the wrong
way round.
However, it relies on cell A1 being available to create the -1 in the
clipboard.
The drawback with this is that it doesn't work on protected sheets (unless
A1 is unprotected, of course).
Is there a better way of putting -1 into the clipboard ?
Sub Paste_Minus()
' Check that a file is open before attempting to run the procedure
If IsFileOpen() = False Then Exit Sub
' cFormula is the formula contained in cell A1
cFormula = Range("A1").Formula
Range("A1").Value = -1
Range("A1").Copy
Selection.PasteSpecial Paste:=xlValues, Operation:=xlMultiply,
SkipBlanks _
:=False, Transpose:=False
' Return the original formula in A1
Range("A1").Formula = cFormula
End Sub