+ Reply to Thread
Results 1 to 4 of 4

To convert the numbers in a given column into negative values

  1. #1
    Registered User
    Join Date
    02-07-2014
    Location
    Vadodara
    MS-Off Ver
    Excel 2010
    Posts
    1

    Question To convert the numbers in a given column into negative values

    Hi guys,

    I want to convert values of a particular column say "M", right from row no 21 to 25 into negative values from the positive values. Consider the values in these cells to be 10,20,30,40 and 50.The code written is:

    Sub negative()
    Range("m21").Activate
    noofout = InputBox("How many times has the stock been issued?")
    For Count = 1 To noofout
    a = ActiveCell.Offset(Count - 1, 0).Value
    ActiveCell.Value = 0
    ActiveCell.Offset(Count - 1, 0).Value = 0 - a
    Next Count
    End Sub

    I suppose the code is absolutely perfect. But still the first cell i.e "M21" gives the result "0" (Zero) instead of the negative value.
    I tried a lot to find the bug/error in this code yet it has not been found. Please help me to locate it.

    Thanks & Regards,
    Mihir Manohar.

  2. #2
    Forum Expert judgeh59's Avatar
    Join Date
    02-07-2013
    Location
    Boise, Idaho
    MS-Off Ver
    Excel 2010
    Posts
    2,308

    Re: To convert the numbers in a given column into negative values

    does taking out the ActiveCell.Value = 0 fix your problem?
    Ernest

    Please consider adding a * if I helped

    Nothing drives me crazy - I'm always close enough to walk....

  3. #3
    Forum Guru
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,445

    Re: To convert the numbers in a given column into negative values

    No need to loop

    Put the value of H1 to -1 and run this code. You can change the cell address of H1 to your choice.

    Please Login or Register  to view this content.

  4. #4
    Valued Forum Contributor
    Join Date
    03-21-2013
    Location
    cyberia
    MS-Off Ver
    Excel 2007
    Posts
    457

    Re: To convert the numbers in a given column into negative values

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Convert negative numbers into positive ones
    By no.18shirt in forum Excel General
    Replies: 3
    Last Post: 05-16-2013, 08:01 AM
  2. Convert negative to positive in sheet containing both positive/negative numbers
    By sa02000 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-29-2010, 07:52 PM
  3. Replies: 4
    Last Post: 07-07-2006, 02:25 PM
  4. [SOLVED] convert negative numbers to positive numbers and vice versa
    By bill gras in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 12-06-2005, 09:45 PM
  5. Replies: 3
    Last Post: 03-24-2005, 03:06 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1