+ Reply to Thread
Results 1 to 2 of 2

Conditional if statement for numerical value

Hybrid View

  1. #1
    Registered User
    Join Date
    04-28-2010
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    26

    Conditional if statement for numerical value

    I'm struggling to write a conditional if statement in vba.
    I have a file which needs to be converted to a particualr format.
    The file contains accounts and amounts in specific cells.
    For all account numbers that begin with 1 ( eg 103067, 121256), I want the amounts to remain intact.
    For all accounts that begin with 2( eg 250466,203093) I want the amounts to be multiplied by -1.
    Every month, the file will have different account numbers in those cells, so I cant record a macro to acheive this.
    How do I write code for this?

    ---------------------
    Thats a great place for me to start...thanks so much!
    Last edited by excel_vb; 06-22-2010 at 01:53 PM.

  2. #2
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591

    Re: Conditional if statement for numerical value

    Hi

    You will have to change the cell selection method, but something like this.

    If Left(ActiveCell.Value, 1) = "2" Then ActiveCell.Value = -ActiveCell.Value
    HTH

    rylo

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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