We’d like to remind Forumites to please avoid political debate on the Forum.

This is to keep it a safe and useful space for MoneySaving discussions. Threads that are – or become – political in nature may be removed in line with the Forum’s rules. Thank you for your understanding.

📨 Have you signed up to the Forum's new Email Digest yet? Get a selection of trending threads sent straight to your inbox daily, weekly or monthly!
The Forum now has a brand new text editor, adding a bunch of handy features to use when creating posts. Read more in our how-to guide

Help On Excel Required.

Hi,
Im not a total begginer with excel i know quite a few things and how to do them. But one thing im puzzled about, is that in a cell (J7) i have two numbers, seperated by a comma and then a space.
Is there a forumala which is able to seperate these, and if not guessing that it will have to be a macro how can i go about it?
Thanks

Comments

  • Select cell
    Choose Tools, Text to Column
    change delimiter to be ,
    done
  • Sorry under Data not under Tools
    (keep delimited selected then for delimiter if you select , and space you don't get space before number)
    then finish
  • trcooke
    trcooke Posts: 309 Forumite
    First number before the comma-space
    =LEFT(A1;FIND(", "; A1)-1)
    
    Second number after the comma-space
    =MID(A1;FIND(", ";A1)+1;LEN(A1))
    
  • Thanks thats sorted! :-)
    Now another quick little problem.
    I want a macro that calculates that if a cell is equal to 1, then it should add one to cell A1.
    How would this be done?
    Thanks
  • trcooke
    trcooke Posts: 309 Forumite
    So what you really want to do is count how many times '1' appears in a range of cells right? If so then you don't need a macro, just the following formula in cell A1:
    =COUNTIF(B1:B12;1)
    
    replace B1:B12 with your range of cells.
  • Not really...but ive scraped that anyway now!
    But is there a way to automatically run a macro when the sum of range of cells is equal to zero?
    Thanks
  • trcooke
    trcooke Posts: 309 Forumite
    What do you want your macro to do? If you just want the cell to change colour or something simple like that then all you'd need to do is set up some conditional formatting for that cell.

    If you really do want to run a macro then be prepared for a steep learning curve as they're not as easy as the basic formula's you've been asking about so far.
  • PhilCo_2
    PhilCo_2 Posts: 136 Forumite
    If you right click on the sheet tab and go to View Code and put this in...

    Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
    Dim sumrange As Range
    Set sumrange = Sheets("sheet1").Range("B4:B6")
    If Application.WorksheetFunction.Sum(sumrange) = 0 Then
    MsgBox "Range = 0"
    Else
    End If

    End Sub

    it will run everytime the sheet is changed and bring up a messagebox when the value of B4:B6 on sheet 1 equals 0. You'll just need to change the sheet and range to match and change the messagebox bit to whatever calculation you want.
This discussion has been closed.
Meet your Ambassadors

🚀 Getting Started

Hi new member!

Our Getting Started Guide will help you get the most out of the Forum

Categories

  • All Categories
  • 353.5K Banking & Borrowing
  • 254.1K Reduce Debt & Boost Income
  • 455K Spending & Discounts
  • 246.6K Work, Benefits & Business
  • 602.9K Mortgages, Homes & Bills
  • 178.1K Life & Family
  • 260.6K Travel & Transport
  • 1.5M Hobbies & Leisure
  • 16K Discuss & Feedback
  • 37.7K Read-Only Boards

Is this how you want to be seen?

We see you are using a default avatar. It takes only a few seconds to pick a picture.