Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > microsoft.public.excel.programming > #111317 > unrolled thread

VBA code to change numeric value to string

Started byhbj <hakan.bjorkstrom@gmail.com>
First post2020-01-20 04:36 -0800
Last post2020-01-25 08:35 -0800
Articles 6 — 4 participants

Back to article view | Back to microsoft.public.excel.programming


Contents

  VBA code to change numeric value to string hbj <hakan.bjorkstrom@gmail.com> - 2020-01-20 04:36 -0800
    Re: VBA code to change numeric value to string Claus Busch <claus_busch@t-online.de> - 2020-01-20 13:39 +0100
      Re: VBA code to change numeric value to string hbj <hakan.bjorkstrom@gmail.com> - 2020-01-21 07:53 -0800
        Re: VBA code to change numeric value to string GS <gs@v.invalid> - 2020-01-21 12:41 -0500
          Re: VBA code to change numeric value to string Lepista <Lepista.186dd008@excelbanter.com> - 2020-01-22 09:41 +0000
            Re: VBA code to change numeric value to string hbj <hakan.bjorkstrom@gmail.com> - 2020-01-25 08:35 -0800

#111317 — VBA code to change numeric value to string

Fromhbj <hakan.bjorkstrom@gmail.com>
Date2020-01-20 04:36 -0800
SubjectVBA code to change numeric value to string
Message-ID<c699f08c-a06d-40e6-9d11-034aaf0968ba@googlegroups.com>
The values entered in a column should always be of string type. If the user enters a numeric value it should be changed to string. Example: if the user enters 100 it should be presented as "00100". I have tried a code into Worksheet.Change() with Cells(TargetRow,TargetColumn).value = "00100". The cell value does not change.

Hakan

[toc] | [next] | [standalone]


#111318

FromClaus Busch <claus_busch@t-online.de>
Date2020-01-20 13:39 +0100
Message-ID<r04723$4l8$1@dont-email.me>
In reply to#111317
Hi Hakan,

Am Mon, 20 Jan 2020 04:36:43 -0800 (PST) schrieb hbj:

> The values entered in a column should always be of string type. If the user enters a numeric value it should be changed to string. Example: if the user enters 100 it should be presented as "00100". I have tried a code into Worksheet.Change() with Cells(TargetRow,TargetColumn).value = "00100". The cell value does not change.

why don't you use a custom number format: 00000


Regards
Claus B.
-- 
Windows10
Office 2016

[toc] | [prev] | [next] | [standalone]


#111319

Fromhbj <hakan.bjorkstrom@gmail.com>
Date2020-01-21 07:53 -0800
Message-ID<3b0d8b0f-fbbb-49e5-a57a-51835e2b6efe@googlegroups.com>
In reply to#111318
On Monday, January 20, 2020 at 2:39:43 PM UTC+2, Claus Busch wrote:
> Hi Hakan,
> 
> Am Mon, 20 Jan 2020 04:36:43 -0800 (PST) schrieb hbj:
> 
> > The values entered in a column should always be of string type. If the user enters a numeric value it should be changed to string. Example: if the user enters 100 it should be presented as "00100". I have tried a code into Worksheet.Change() with Cells(TargetRow,TargetColumn).value = "00100". The cell value does not change.
> 
> why don't you use a custom number format: 00000
> 
> 
> Regards
> Claus B.
> -- 
> Windows10
> Office 2016

Because that is only a presentation value - the real value will still remain numeric i.e. 100. 00100 is a zip code which will be forwarded to an external mail merging program.

Håkan

[toc] | [prev] | [next] | [standalone]


#111320

FromGS <gs@v.invalid>
Date2020-01-21 12:41 -0500
Message-ID<r07d3n$g91$1@dont-email.me>
In reply to#111319
> On Monday, January 20, 2020 at 2:39:43 PM UTC+2, Claus Busch wrote:
>> Hi Hakan,
>> 
>> Am Mon, 20 Jan 2020 04:36:43 -0800 (PST) schrieb hbj:
>> 
>>> The values entered in a column should always be of string type. If the user 
>>> enters a numeric value it should be changed to string. Example: if the user 
>>> enters 100 it should be presented as "00100". I have tried a code into 
>>> Worksheet.Change() with Cells(TargetRow,TargetColumn).value = "00100". The 
>>> cell value does not change.
>> 
>> why don't you use a custom number format: 00000
>> 
>> 
>> Regards
>> Claus B.
>> -- 
>> Windows10
>> Office 2016
>
> Because that is only a presentation value - the real value will still remain 
> numeric i.e. 100. 00100 is a zip code which will be forwarded to an external 
> mail merging program.
>
> Håkan

Zip Code is a built-in 'Special' format so typing 100 displays as 00100; - why 
not use it?

-- 
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
  comp.lang.basic.visual.misc
  microsoft.public.vb.general.discussion

[toc] | [prev] | [next] | [standalone]


#111321

FromLepista <Lepista.186dd008@excelbanter.com>
Date2020-01-22 09:41 +0000
Message-ID<Lepista.186dd008@excelbanter.com>
In reply to#111320
=TEXT({number},"00000")




-- 
Lepista

[toc] | [prev] | [next] | [standalone]


#111322

Fromhbj <hakan.bjorkstrom@gmail.com>
Date2020-01-25 08:35 -0800
Message-ID<bc745b06-c1e7-477e-8353-d37d25a5142e@googlegroups.com>
In reply to#111321
On Wednesday, January 22, 2020 at 11:49:15 AM UTC+2, Lepista wrote:
> =TEXT({number},"00000")
> 
> 
> 
> 
> -- 
> Lepista

Thank you. I'll give it a try.

Håkan

[toc] | [prev] | [standalone]


Back to top | Article view | microsoft.public.excel.programming


csiph-web