BBlu
asked on
Working with Range VBA
I'm new to VBA, trying to learn as quickly as I can. I am trying to do what I think is a simple task, but it's not working. I simply want to select a group of cells, then change the sign (multiply by -1). I'm not sure why. Could someone help?
Sub Changesign(ByVal numsToChange As Range)
Dim checkRange As Range
For Each checkRange In numsToChange
checkRange = checkRange * -1
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you all. I'm not sure what I'm doing wrong here. I've edited mine according to the first response and added another just for testing and learning. But neither appears in my macros list when I try to run them. See attached.
ScreenShot-ChangeSign1.png
ScreenShot-ChangeSign1.png
The macros list will not show macros that take a parameter as yours does. You need to create a macro that has no parameter and calls yours, like
Sub TestChange()
Call ChangeSign(Selection)
End Sub
ASKER
Thank you all
ASKER
As usual, Awesome! Thanks to you all.
Next checkrange
after checkRange = checkRange * -1