Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
How do i make all the numbers in Column A1 to A7 Negative using VB
Script? --- Message posted from http://www.ExcelForum.com/ |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi
why use VBA?. one way (without VBA) would be the following - enter '-1' in a blank cell - copy this cell (CTRL+C) - select A1:A7 - goto 'Edit - Paste Special' and choose 'Multiply' as action For a VBA solution you may try the following macro (makes all numbers negative in the current selection - already negative numbers won't be altered) Public Sub make_negative() Dim c As Range For Each c In Selection If c.Value 0 Then c.Value = -c.Value End If Next End Sub Note: no error checking included for strings, etc. -- Regards Frank Kabel Frankfurt, Germany How do i make all the numbers in Column A1 to A7 Negative using VB Script? --- Message posted from http://www.ExcelForum.com/ |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Sub macro1()
For Each c In Range("A1:A7").Cells c.Value = 0 - c.Value Next End Sub Note: I subtracted from zero, you could also multiply by - 1. |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
This will work whether the cells have a negative or positive value.
Sub neg_Value() Dim aaa As Range For Each aaa In Range("A1:A7") aaa = -Abs(aaa) 'if you want them to be positive, remove "-" Next End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How do I subtract a negative number from a positive number? | Excel Discussion (Misc queries) | |||
Change positive number to negative number | Excel Worksheet Functions | |||
Converting Negative Number to Postive number | Excel Worksheet Functions | |||
Converting a negative number to a positive number | Excel Discussion (Misc queries) | |||
2003= negative number&2004= negative number How Do I Calculate gro | Excel Worksheet Functions |