How do I format numbers so it will show the actual first digit, and then the rest as "x"?

GoUmass

New Member
Joined
Aug 5, 2013
Messages
2
How do I format numbers so it will show the actual first digit, and the rest as x?

so that $1,234.56

will appear as $1,xxx.xx

or alternatively,

$1,234,567.89

will appear as $1,xxx,xxx.xx

I would prefer to do this with custom formatting rather than VBA, but any means possible would be appreciated.


(this is so I can generate sample reports for prospective clients, without showing the real numbers in the tables)

Thanks!
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.

apo

Well-known Member
Joined
Nov 3, 2008
Messages
581
Hi..

By adapting Rick Rothsteins code form here:
http://www.mrexcel.com/forum/excel-questions/682393-remove-numeric-characters-string.html

Add this UDF to a Module..

Code:
Function NoDigits(S As String) As String
  Dim X As Long
  NoDigits = Mid(S, 2, (Len(S)))
  For X = 0 To 9
    NoDigits = Replace(NoDigits, X, "x")
  Next
  NoDigits = Left(S, 2) & NoDigits
End Function

You just gotta make sure your initial values are formatted as Text or it wont pick up the commas..

<b>Sheet1</b><br /><br /><table border="1" cellspacing="0" cellpadding="0" style="font-family:Calibri,Arial; font-size:11pt; background-color:#ffffff; padding-left:2pt; padding-right:2pt; "> <colgroup><col style="font-weight:bold; width:30px; " /><col style="width:144px;" /><col style="width:128px;" /><col style="width:161px;" /></colgroup><tr style="background-color:#cacaca; text-align:center; font-weight:bold; font-size:8pt; "><td > </td><td >A</td><td >B</td><td >C</td></tr><tr style="height:18px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >1</td><td style="text-align:right; ">$123,456.78</td><td >$1xxx,xxx.xx</td><td > </td></tr><tr style="height:18px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >2</td><td style="text-align:right; ">$823,456.79</td><td >$8xxx,xxx.xx</td><td >$1xxx,xxx,xx</td></tr><tr style="height:18px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >3</td><td style="text-align:right; ">$253,456.80</td><td >$2xxx,xxx.xx</td><td >$7xxx,xxx,xx</td></tr><tr style="height:18px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >4</td><td style="text-align:right; ">$123,456.81</td><td >$1xxx,xxx.xx</td><td > </td></tr><tr style="height:18px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >5</td><td style="text-align:left; ">$323,456.82</td><td >$3xxx,xxx.xx</td><td > </td></tr><tr style="height:18px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >6</td><td style="text-align:right; ">$123,456.83</td><td >$1xxx,xxx.xx</td><td > </td></tr><tr style="height:18px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >7</td><td style="text-align:right; ">$123,456.84</td><td >$1xxx,xxx.xx</td><td > </td></tr><tr style="height:18px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >8</td><td style="text-align:right; ">$123,456.85</td><td >$1xxx,xxx.xx</td><td > </td></tr><tr style="height:18px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >9</td><td style="text-align:right; ">$123,456.86</td><td >$1xxx,xxx.xx</td><td > </td></tr><tr style="height:18px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >10</td><td style="text-align:right; ">$123,456.87</td><td >$1xxx,xxx.xx</td><td > </td></tr><tr style="height:18px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >11</td><td style="text-align:right; ">$123,456.88</td><td >$1xxx,xxx.xx</td><td > </td></tr><tr style="height:18px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >12</td><td style="text-align:right; ">$123,456.89</td><td >$1xxx,xxx.xx</td><td > </td></tr><tr style="height:18px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >13</td><td style="text-align:right; ">$123,456.90</td><td >$1xxx,xxx.xx</td><td > </td></tr><tr style="height:18px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >14</td><td style="text-align:right; ">$123,456.91</td><td >$1xxx,xxx.xx</td><td > </td></tr><tr style="height:18px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >15</td><td style="text-align:right; ">$123,456.92</td><td >$1xxx,xxx.xx</td><td > </td></tr><tr style="height:18px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >16</td><td style="text-align:right; ">$123,456.93</td><td >$1xxx,xxx.xx</td><td > </td></tr><tr style="height:18px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >17</td><td style="text-align:right; ">$123,456.94</td><td >$1xxx,xxx.xx</td><td > </td></tr></table><br /><table style="font-family:Arial; font-size:10pt; border-style: groove ;border-color:#00ff00;background-color:#fffcf9; color:#000000; "><tr><td ><b>Spreadsheet Formulas</b></td></tr><tr><td ><table border = "1" cellspacing="0" cellpadding="2" style="font-family:Arial; font-size:9pt;"><tr style="background-color:#cacaca; font-size:10pt;"><td >Cell</td><td >Formula</td></tr><tr><td >B1</td><td >=NoDigits(A1)</td></tr><tr><td >B2</td><td >=NoDigits(A2)</td></tr><tr><td >C2</td><td >=NoDigits("$123,456,89")</td></tr><tr><td >B3</td><td >=NoDigits(A3)</td></tr><tr><td >C3</td><td >=NoDigits("$723,456,89")</td></tr><tr><td >B4</td><td >=NoDigits(A4)</td></tr><tr><td >B5</td><td >=NoDigits(A5)</td></tr><tr><td >B6</td><td >=NoDigits(A6)</td></tr><tr><td >B7</td><td >=NoDigits(A7)</td></tr><tr><td >B8</td><td >=NoDigits(A8)</td></tr><tr><td >B9</td><td >=NoDigits(A9)</td></tr><tr><td >B10</td><td >=NoDigits(A10)</td></tr><tr><td >B11</td><td >=NoDigits(A11)</td></tr><tr><td >B12</td><td >=NoDigits(A12)</td></tr><tr><td >B13</td><td >=NoDigits(A13)</td></tr><tr><td >B14</td><td >=NoDigits(A14)</td></tr><tr><td >B15</td><td >=NoDigits(A15)</td></tr><tr><td >B16</td><td >=NoDigits(A16)</td></tr><tr><td >B17</td><td >=NoDigits(A17)</td></tr></table></td></tr></table> <br />Excel tables to the web - Excel Jeanie Html 4
 

Forum statistics

Threads
1,171,881
Messages
5,878,035
Members
433,312
Latest member
SilentSam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top