Excel - Copy the displayed value not the actual value

后端 未结 3 854
Happy的楠姐
Happy的楠姐 2021-01-18 01:33

I am a pilot, and use a logbook program called Logten Pro. I have the ability to take excel spreadsheets saved from my work flight management software, and import them into

相关标签:
3条回答
  • 2021-01-18 02:00

    I'm a bit late to the party on this one, but recently came across this as was searching for answers to a similar problem.

    Here is the answer I finally came up with.

    Option Explicit
    
    Sub ValuesToDisplayValues()
    
        Dim ThisRange As Range, ThisCell As Range
    
        Set ThisRange = Selection
    
        For Each ThisCell In ThisRange
    
            ThisCell.Value = WorksheetFunction.Text(ThisCell.Value, ThisCell.NumberFormat)
    
        Next ThisCell
    
    End Sub
    

    This answers the question as asked, apart from the new values are pasted over the existing ones, not into a new cell, as there is no simple way to know where you would want the new values to be pasted. It will work on the whole range of selected cells, so you can do a whole column if needed.

    0 讨论(0)
  • 2021-01-18 02:09

    There are three options using formulas.

    Rounddown

    Excel stores the date time as a number and uses formatting to display it as a date. The format is date.time, where the integer is the date and the fraction is the time.

    As an example 01/01/2012 10:30:00 PM is stored as 40909.9375

    All the values after the decimal place relate to the hours and minutes

    So a formula could be used to round the number down to a whole number.

    =ROUNDDOWN(A1,0)
    

    Then format the value as a short date. It will then display as 01/01/2012

    INT

    As above, but using a different formula to get rid of the fraction (time)

    =INT(A1)
    

    Text

    Alternately the date only could be extracted as text using this formula

    =TEXT(A1,"dd/mm/yyyy")
    

    It will then display as 01/01/2012

    0 讨论(0)
  • 2021-01-18 02:16

    As pointed out in the comments, you'd better not use VBA but formulas instead.

    This formula:

    TEXT(A1,"dd-mm-yyy")
    

    will return the formated date in a text way. You can drag and drop the formula in the whole range of your cells and Copy/Paste Special > Values so that you will only have the needed values to get imported in Logten Pro.

    0 讨论(0)
提交回复
热议问题