+ Reply to Thread
Results 1 to 8 of 8

Multiply if Column Contains Certain Text

  1. #1
    Registered User
    Join Date
    04-25-2014
    Location
    NYC, NY
    MS-Off Ver
    Excel 2010
    Posts
    44

    Multiply if Column Contains Certain Text

    I have column A that declares the account as asset, liability, expense, etc. Some of the accounts need to be reversed. I'm having a hard time figuring out a formula or code I can use. Column C contains the values. I prefer VBA as I want to add it to the current macro I already have.

    So if Column A has a liability, offset by (0,2), and multiply that value by -1. If Column A has an asset, leave the value as is.

    I wanted to use an if-then statement but I'm not sure how to highlight entire columns. The number of liabilities, and assets, etc. will vary so I'm stuck.

    Any help would be great.

  2. #2
    Registered User
    Join Date
    07-30-2014
    Location
    india
    MS-Off Ver
    2007
    Posts
    43

    Re: Multiply if Column Contains Certain Text

    try this

    Sub k()


    For i = 1 To 24

    SkipBlanks = False

    If Cells(i, 1).Value = "liability" Then

    Cells(i, 2).Value = Cells(i, 2).Value * -1

    End If
    Next i

    End Sub

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

    Re: Multiply if Column Contains Certain Text

    this should get you started....I think

    Please Login or Register  to view this content.
    Ernest

    Please consider adding a * if I helped

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

  4. #4
    Registered User
    Join Date
    04-25-2014
    Location
    NYC, NY
    MS-Off Ver
    Excel 2010
    Posts
    44

    Re: Multiply if Column Contains Certain Text

    Thanks for the quick responses guys. I just did a formula and it seems to work, but maybe you guys can see some flaws with this.

    Using VBA, I would add a column and use this code:
    Please Login or Register  to view this content.
    I would hide the column with the original values and it would show the results from the formula above. I will just nest in the other accounts.

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

    Re: Multiply if Column Contains Certain Text

    is it working for you? (POST #4)

  6. #6
    Registered User
    Join Date
    04-25-2014
    Location
    NYC, NY
    MS-Off Ver
    Excel 2010
    Posts
    44

    Re: Multiply if Column Contains Certain Text

    It is, but I just decided to adapt your code instead. I would have to add and hide columns, and would make it more messy. I'm still kind of surprised my formula works.

    Thanks again for the code, I'm still new to VBA but I'm learning quickly.

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

    Re: Multiply if Column Contains Certain Text

    If this has been completed to your satisfaction, please set the thread to Solved...If you feel we deserve an increase in our reputation, feel free to click on the star in the lower left of the thread. Remember, someday when you help somebody they may add to your rep points, and it could be us...just a thought...

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

    Re: Multiply if Column Contains Certain Text

    thanks for the points and keep plugging away on the VBA

+ 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. Replies: 1
    Last Post: 07-12-2012, 02:29 PM
  2. Replies: 7
    Last Post: 06-17-2012, 05:03 AM
  3. multiply column
    By jokerboy in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-12-2011, 11:04 AM
  4. Replies: 8
    Last Post: 08-06-2009, 09:02 AM
  5. multiply with - if text
    By potzo in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-02-2006, 08:42 AM

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