M
mviuya
How do we convert positive numbers into negative ones under one column?
How do we convert positive numbers into negative ones under one column?
Héctor Miguel said:hi, !
How do we convert positive numbers into negative ones under one column?
do you have any mixture of positives and negatives in "the range" ?
if so, and you want negatives "as is" and positives into negatives...
pretending "the range" in [A2:A35] -???-
try from vba-editor > immediate window pane
(copy/paste or type) the following and press enter...
[a2:a35] = [a2:a35*-1^(a2:a35>0)]
hth,
hector.
Hola Hector,
What is wrong with the following:
Var1 = 30
[F4:F&Var1] = [F4:F&Var1*-1]
Note1: all values are positive
Note2: using F30 instead of F&Var1 works, but the column list will always be
different. (Yes, the actual variable is "Dim"ed and uses a routine to find
the last row.)
Question: what is wrong with the syntax? What is the proper way of
combining F with Var1? F&Var1 does not work.
Saludos
Héctor Miguel said:hi, !
How do we convert positive numbers into negative ones under one column?
do you have any mixture of positives and negatives in "the range" ?
if so, and you want negatives "as is" and positives into negatives...
pretending "the range" in [A2:A35] -???-
try from vba-editor > immediate window pane
(copy/paste or type) the following and press enter...
[a2:a35] = [a2:a35*-1^(a2:a35>0)]
hth,
hector.
Dave Peterson said:I'd do something like:
Option Explicit
Sub testme01()
Dim myCell As Range
Dim Var1 As Long
Var1 = 30
With ActiveSheet
Set myCell = .Cells.SpecialCells(xlCellTypeLastCell).Offset(1, 1)
myCell.Value = -1
myCell.Copy
.Range("f4:F" & Var1).PasteSpecial _
operation:=xlPasteSpecialOperationMultiply
myCell.ClearContents
End With
End Sub
This is the same thing as putting -1 in an empty cell and then edit|copy that
cell.
Then select the range to adjust
Edit|paste special|multiply
and clearing that helper cell.
Hola Hector,
What is wrong with the following:
Var1 = 30
[F4:F&Var1] = [F4:F&Var1*-1]
Note1: all values are positive
Note2: using F30 instead of F&Var1 works, but the column list will always be
different. (Yes, the actual variable is "Dim"ed and uses a routine to find
the last row.)
Question: what is wrong with the syntax? What is the proper way of
combining F with Var1? F&Var1 does not work.
Saludos
Héctor Miguel said:hi, !
How do we convert positive numbers into negative ones under one column?
do you have any mixture of positives and negatives in "the range" ?
if so, and you want negatives "as is" and positives into negatives...
pretending "the range" in [A2:A35] -???-
try from vba-editor > immediate window pane
(copy/paste or type) the following and press enter...
[a2:a35] = [a2:a35*-1^(a2:a35>0)]
hth,
hector.
Thanks Dave,
It works like a charm! I don't have the slightest about the code, so I have
to store it in my "Tool Box" and just know that if I set it up right, I can
use it any time I face the same situation.
Dave Peterson said:I'd do something like:
Option Explicit
Sub testme01()
Dim myCell As Range
Dim Var1 As Long
Var1 = 30
With ActiveSheet
Set myCell = .Cells.SpecialCells(xlCellTypeLastCell).Offset(1, 1)
myCell.Value = -1
myCell.Copy
.Range("f4:F" & Var1).PasteSpecial _
operation:=xlPasteSpecialOperationMultiply
myCell.ClearContents
End With
End Sub
This is the same thing as putting -1 in an empty cell and then edit|copy that
cell.
Then select the range to adjust
Edit|paste special|multiply
and clearing that helper cell.
Hola Hector,
What is wrong with the following:
Var1 = 30
[F4:F&Var1] = [F4:F&Var1*-1]
Note1: all values are positive
Note2: using F30 instead of F&Var1 works, but the column list will always be
different. (Yes, the actual variable is "Dim"ed and uses a routine to find
the last row.)
Question: what is wrong with the syntax? What is the proper way of
combining F with Var1? F&Var1 does not work.
Saludos
:
hi, !
How do we convert positive numbers into negative ones under one column?
do you have any mixture of positives and negatives in "the range" ?
if so, and you want negatives "as is" and positives into negatives...
pretending "the range" in [A2:A35] -???-
try from vba-editor > immediate window pane
(copy/paste or type) the following and press enter...
[a2:a35] = [a2:a35*-1^(a2:a35>0)]
hth,
hector.
Dave Peterson said:I think doing it manually is much quicker than finding the macro, installing it,
modifying it for the correct range, and then running it.
Thanks Dave,
It works like a charm! I don't have the slightest about the code, so I have
to store it in my "Tool Box" and just know that if I set it up right, I can
use it any time I face the same situation.
Dave Peterson said:I'd do something like:
Option Explicit
Sub testme01()
Dim myCell As Range
Dim Var1 As Long
Var1 = 30
With ActiveSheet
Set myCell = .Cells.SpecialCells(xlCellTypeLastCell).Offset(1, 1)
myCell.Value = -1
myCell.Copy
.Range("f4:F" & Var1).PasteSpecial _
operation:=xlPasteSpecialOperationMultiply
myCell.ClearContents
End With
End Sub
This is the same thing as putting -1 in an empty cell and then edit|copy that
cell.
Then select the range to adjust
Edit|paste special|multiply
and clearing that helper cell.
Billyruben wrote:
Hola Hector,
What is wrong with the following:
Var1 = 30
[F4:F&Var1] = [F4:F&Var1*-1]
Note1: all values are positive
Note2: using F30 instead of F&Var1 works, but the column list will always be
different. (Yes, the actual variable is "Dim"ed and uses a routine to find
the last row.)
Question: what is wrong with the syntax? What is the proper way of
combining F with Var1? F&Var1 does not work.
Saludos
:
hi, !
How do we convert positive numbers into negative ones under one column?
do you have any mixture of positives and negatives in "the range" ?
if so, and you want negatives "as is" and positives into negatives...
pretending "the range" in [A2:A35] -???-
try from vba-editor > immediate window pane
(copy/paste or type) the following and press enter...
[a2:a35] = [a2:a35*-1^(a2:a35>0)]
hth,
hector.
Hi Dave, I'll agree with you if we are talking about an occasional use of
it. What I didn't share with you is that procedure is but one step in a long
series of steps within a process which will be used several times during each
month. I worded my question in such a way as to not get the issue buried
within the bigger picture. I don't actually program so given that this would
be an ongoing routine, I captured each Excel step using the Macro Recorder.
I then proceeded to string all those macros together into one small,
functional program. A lot of the modifications were intuitive or logical,
but there have been three questions involving syntax that have made me yell
"uncle." Fortunately you folks out in the community have been more than
helpful in reponding to my requests for assistance. Keep an ear to the
ground, you'll probably see more questions posted by me. Thanks for being
out there to help non-programmers.
Dave Peterson said:I think doing it manually is much quicker than finding the macro, installing it,
modifying it for the correct range, and then running it.
Thanks Dave,
It works like a charm! I don't have the slightest about the code, so I have
to store it in my "Tool Box" and just know that if I set it up right, I can
use it any time I face the same situation.
:
I'd do something like:
Option Explicit
Sub testme01()
Dim myCell As Range
Dim Var1 As Long
Var1 = 30
With ActiveSheet
Set myCell = .Cells.SpecialCells(xlCellTypeLastCell).Offset(1, 1)
myCell.Value = -1
myCell.Copy
.Range("f4:F" & Var1).PasteSpecial _
operation:=xlPasteSpecialOperationMultiply
myCell.ClearContents
End With
End Sub
This is the same thing as putting -1 in an empty cell and then edit|copy that
cell.
Then select the range to adjust
Edit|paste special|multiply
and clearing that helper cell.
Billyruben wrote:
Hola Hector,
What is wrong with the following:
Var1 = 30
[F4:F&Var1] = [F4:F&Var1*-1]
Note1: all values are positive
Note2: using F30 instead of F&Var1 works, but the column list will always be
different. (Yes, the actual variable is "Dim"ed and uses a routine to find
the last row.)
Question: what is wrong with the syntax? What is the proper way of
combining F with Var1? F&Var1 does not work.
Saludos
:
hi, !
How do we convert positive numbers into negative ones under one column?
do you have any mixture of positives and negatives in "the range" ?
if so, and you want negatives "as is" and positives into negatives...
pretending "the range" in [A2:A35] -???-
try from vba-editor > immediate window pane
(copy/paste or type) the following and press enter...
[a2:a35] = [a2:a35*-1^(a2:a35>0)]
hth,
hector.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.