Excel - How to get expression text rather than the value

Harry Ninh

I'm having problem with a big set of Excel data. One others had inputted the data like this:

A
10
10:12
11:12:15

My task is to convert it to something like this:

B
Pig
Pig:Koala
Dog:Koala:Bird

I was trying to use substitute:

= SUBSTITUTE(A1, "10", "Pig")

But the problem is, Excel recognizes those value in A column as other data types (number, time...) and the SUBSTITUTE doesn't work on those types.

How could I fix this issue?

Thank you.

SeanC

This function will return a string that matches what excel is displaying.

Option Explicit

Function ToText(r As Range) As String
If r.Count <> 1 Then
    ToText = "#ERR!"
    Exit Function
End If
ToText = IIf(r.NumberFormat = "General", CStr(r.Value), Format(r.Value, r.NumberFormat))
End Function

for example, if 10:11:12 is in A1, which excel thinks is a time, and is formatted this way, then =ToText(A1) will return the string 10:11:12, which you can then manipulate as you would any other text

put this into a module on the spreadsheet ( ALT + F11 ) so the function is available to excel

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to get a function that returns an expression to be called rather than interpreted as an expression

From Dev

How do you get buttons to be aligned by their borders rather than their text?

From Dev

How to get CSS height value (rather than calculated height) in jQuery

From Dev

How to get a value from an <input> rather than a prompt?

From Dev

How do I show text rather than boolean value (Yii2)?

From Dev

How do I get python to search text for one word in a list rather than all the words in a list?

From Dev

How to get actual move rather than move value from mini max algorithm

From Dev

h:graphicimage value attribute: how to get path of server rather than webapp context root

From Dev

How to get actual move rather than move value from mini max algorithm

From Dev

How can I get an element in an array based on value rather than index with Json.NET in C#?

From Dev

How to get column value rather than ID in yii2 by using javascript

From Dev

How to use onclick with a function expression rather than a declared function?

From Dev

Lambda Expression: How to map to a List rather than IEnumerable?

From Dev

ComboBox value rather than text is displayed when an option is selected

From Dev

(() => {}) rather than the JavaScript function expression

From Dev

Get value from IO rather than the computation itself

From Dev

How can I pass in text rather than a file as a variable

From Dev

How can I pass in text rather than a file as a variable

From Dev

Excel DO rather than a range

From Dev

How to start counter from 0 rather than maximum value?

From Dev

Perl - DBI - How to process array rather than single value?

From Dev

How to display variable name itself rather than the value in shell

From Dev

How to store data in Django cache as a reference rather than value.?

From Dev

Python: How to demand a string as input rather than a specific value

From Dev

How to get more than one value of text box using in condition

From Dev

How to get DBGrid to draw Yes/No rather than True/False

From Dev

How to get the values href values rather than the anchor tags?

From Dev

How to get generic types as exchange input body rather than casting?

From Dev

How to get single result as an array rather than a Model in Sequel ORM

Related Related

  1. 1

    How to get a function that returns an expression to be called rather than interpreted as an expression

  2. 2

    How do you get buttons to be aligned by their borders rather than their text?

  3. 3

    How to get CSS height value (rather than calculated height) in jQuery

  4. 4

    How to get a value from an <input> rather than a prompt?

  5. 5

    How do I show text rather than boolean value (Yii2)?

  6. 6

    How do I get python to search text for one word in a list rather than all the words in a list?

  7. 7

    How to get actual move rather than move value from mini max algorithm

  8. 8

    h:graphicimage value attribute: how to get path of server rather than webapp context root

  9. 9

    How to get actual move rather than move value from mini max algorithm

  10. 10

    How can I get an element in an array based on value rather than index with Json.NET in C#?

  11. 11

    How to get column value rather than ID in yii2 by using javascript

  12. 12

    How to use onclick with a function expression rather than a declared function?

  13. 13

    Lambda Expression: How to map to a List rather than IEnumerable?

  14. 14

    ComboBox value rather than text is displayed when an option is selected

  15. 15

    (() => {}) rather than the JavaScript function expression

  16. 16

    Get value from IO rather than the computation itself

  17. 17

    How can I pass in text rather than a file as a variable

  18. 18

    How can I pass in text rather than a file as a variable

  19. 19

    Excel DO rather than a range

  20. 20

    How to start counter from 0 rather than maximum value?

  21. 21

    Perl - DBI - How to process array rather than single value?

  22. 22

    How to display variable name itself rather than the value in shell

  23. 23

    How to store data in Django cache as a reference rather than value.?

  24. 24

    Python: How to demand a string as input rather than a specific value

  25. 25

    How to get more than one value of text box using in condition

  26. 26

    How to get DBGrid to draw Yes/No rather than True/False

  27. 27

    How to get the values href values rather than the anchor tags?

  28. 28

    How to get generic types as exchange input body rather than casting?

  29. 29

    How to get single result as an array rather than a Model in Sequel ORM

HotTag

Archive