Excel - Copy the displayed value not the actual value

后端 未结 3 857
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条回答
  •  梦毁少年i
    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.

提交回复
热议问题