How can I copy a bunch of formatted values to a new range and have them as text values exactly the way they were formatted?
for example suppose my Regional Settings are set to French-Canada(note that French-Canada uses a comma for decimal point instead of a period). Note that I choose French-Canada because when the locale is not set to English-US we can experience different behavior than what we normally do.
Suppose I set the following range values:
Range A1:
Value = 1,23
NumberFormat = "[$€-2] #,##0.00"
Displays As: €1,23
Range A2:
Value=0,05
NumberFormat="0.00%"
Displays As: 5,00%
Things I have tried:
a)
Format B1:B2 as Text, Copy A1:A2, Paste Special Values -> Doesn't work converts it to 1,23 and 0,05
b)
set B1's Formula to: =TEXT(A1,"[$€-2] #,##0.00")
set B2's Formula to: =TEXT(A2,"0.00%")
this works when Regional Settings is set to English-US, but not for other Regional Settings like French-Canada:
French Canada will display € 1,230.00, and 0.05% which is wrong
c)
I can create a module with some VBA code and call it via in-cell functions. This works but I don't want to do this.
Public Function TextVBA(r As Range) As String
TextVBA = r.Text
End Function
d)
I can copy the cells, paste them in Notepad, copy the text from Notepad and then paste in Excel. This also works, but I also don't want to do this.
-------------------------------
I am developing a C# addin and using the Text function over and over again is slow due to COM Interop. Using the clipboard is a no-no since it is a shared system resource.
Is there any other way that I can extract the text from one cell to another? I don't mind getting manual steps since I can figure out how to automate them via code.
for example suppose my Regional Settings are set to French-Canada(note that French-Canada uses a comma for decimal point instead of a period). Note that I choose French-Canada because when the locale is not set to English-US we can experience different behavior than what we normally do.
Suppose I set the following range values:
Range A1:
Value = 1,23
NumberFormat = "[$€-2] #,##0.00"
Displays As: €1,23
Range A2:
Value=0,05
NumberFormat="0.00%"
Displays As: 5,00%
Things I have tried:
a)
Format B1:B2 as Text, Copy A1:A2, Paste Special Values -> Doesn't work converts it to 1,23 and 0,05
b)
set B1's Formula to: =TEXT(A1,"[$€-2] #,##0.00")
set B2's Formula to: =TEXT(A2,"0.00%")
this works when Regional Settings is set to English-US, but not for other Regional Settings like French-Canada:
French Canada will display € 1,230.00, and 0.05% which is wrong
c)
I can create a module with some VBA code and call it via in-cell functions. This works but I don't want to do this.
Public Function TextVBA(r As Range) As String
TextVBA = r.Text
End Function
d)
I can copy the cells, paste them in Notepad, copy the text from Notepad and then paste in Excel. This also works, but I also don't want to do this.
-------------------------------
I am developing a C# addin and using the Text function over and over again is slow due to COM Interop. Using the clipboard is a no-no since it is a shared system resource.
Is there any other way that I can extract the text from one cell to another? I don't mind getting manual steps since I can figure out how to automate them via code.