+ Reply to Thread
Results 1 to 9 of 9

Weight Cell Convert

Hybrid View

  1. #1
    Registered User
    Join Date
    01-16-2014
    Location
    uk
    MS-Off Ver
    Excel 2013
    Posts
    99

    Weight Cell Convert

    Hi

    I currently have a sheet i am working on that has four columns to convert from stones to pounds as excel does not recognise the format as there are 14 pounds in a stone and the data i am pasteing appears as (11-7), What i am having to do is e.g (11st x 14lbs + 7lbs = 161lbs) this is using four cells to do the calculation.
    Is there any way i can format the column/cell to recognise when i input data 11-7 to automaticly recognise it and shows 161?

    I only need between 8st & 12st.

    Thanks

  2. #2
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Weight Cell Convert

    Format the A1 Cell as Text

    In A1 Cell

    11-7

    In B1 Cell

    =IFERROR(SUM(LEFT(A1,FIND("-",A1)-1)*14,MID(A1,FIND("-",A1)+1,255)),"-")


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  3. #3
    Registered User
    Join Date
    01-16-2014
    Location
    uk
    MS-Off Ver
    Excel 2013
    Posts
    99

    Re: Weight Cell Convert

    that does reduce the number of cells by half which is great in itself, but i was wondering if it was possible to format the cell i was in to recognise the data input and convert it to pounds all in the same cell once i leave that cell e.g i input 11-7 i leave cell, same cell shows 161?

  4. #4
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Weight Cell Convert

    Copy the below code and do right click on sheet tab and select view code and paste it.

    Close the VBA window (Alt+Q to close VBA window) and return to that sheet and check.

    Private Sub Worksheet_Change(ByVal Target As Range)
    Dim sFormula As String
    
    If Target.Address <> "$A$1" Then Exit Sub
    
    Application.EnableEvents = False
        With Target
            sFormula = "=IFERROR(SUM(LEFT(""" & .Value & """,FIND(""-"",""" & .Value _
            & """)-1)*14,MID(""" & .Value & """,FIND(""-"",""" & .Value & """)+1,255)),""-"")"
            .Value = Evaluate(sFormula)
        End With
    Application.EnableEvents = True
    
    End Sub
    Enter the value in A1 Cell and check....

    Ensure that your entry should start with a single quote ( ' ) so that the numeric entry will be considered as text otherwise excel will convert the entry to real date.

    I restricted the conversion to happen in A1 cell alone.

  5. #5
    Registered User
    Join Date
    01-16-2014
    Location
    uk
    MS-Off Ver
    Excel 2013
    Posts
    99

    Re: Weight Cell Convert

    That is so cool Sixthsense, it works perfectly I just formatted whole column as text and in the code i gather i just change the A1 to where ever i need the code to run and copy formula all the way down?

    I must say this saves a hell of alot of time and reduces space on sheet, lol its fitting that i watched the film Son Of God last night

    Thanks alot

  6. #6
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Weight Cell Convert

    Replace this line

    If Target.Address <> "$A$1" Then Exit Sub
    With

    If Target.Column <> 1 Then Exit Sub
    That will make the code to work in any cell of Column_A


    If you want to set it for Column B then change 1 to 2

+ 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. Auto Calculate Shipping Weight/Cartons and Package Weight.
    By suhailsiddiqui09 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 05-27-2013, 06:48 AM
  2. Excel formula to convert weight quantites
    By Get the cans out in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 01-06-2013, 06:45 PM
  3. Calculating weight
    By br0die in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-21-2012, 12:17 AM
  4. how do i convert weight (stones+llbs) to llbs?
    By dilbert in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-10-2006, 10:30 AM
  5. Weight loss line chart to monitor weight loss progress
    By S Fox in forum Excel Charting & Pivots
    Replies: 6
    Last Post: 11-08-2005, 01:15 PM

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