+ Reply to Thread
Results 1 to 6 of 6

Issues with Environ vba script

  1. #1
    Forum Contributor
    Join Date
    06-03-2008
    MS-Off Ver
    Excel 2007 (also have access to Excel 2000/2003)
    Posts
    368

    Issues with Environ vba script

    Hi,

    When a user launches my spreadsheet the following code is activated (a section of it):

    Please Login or Register  to view this content.
    The problem is users log on with 5 digits i.e 12345. However some usernames start with a 0 for example 01234. When that code is called the cell shows the value without a zero.

    Can I either add to the code to force this to happen. Or is there a way to force the cell to show 5 digits?

    Thank you in advance.
    Last edited by jpruffle; 07-16-2009 at 03:56 PM.

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Issues with Environ vba script

    maybe
    Please Login or Register  to view this content.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,887

    Re: Issues with Environ vba script

    Roy, I've even tried that, and if the cell is formatted as General (or anything other than Text), the leading zeros are still dropped. I got the following to work, though:
    Please Login or Register  to view this content.
    Essentially setting the cell format to text first, which could be done manually I suppose.

  4. #4
    Forum Contributor
    Join Date
    06-03-2008
    MS-Off Ver
    Excel 2007 (also have access to Excel 2000/2003)
    Posts
    368

    Re: Issues with Environ vba script

    Thank you for the reply.

    However as it is not seen as a number other areas of my spreadsheet don't calculate properly.

    I shall have a go at trying to make do with numeric values.

    Thanks again for your help

  5. #5
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Issues with Environ vba script

    You could use a Custom Format on the cell of 00000, this will write back the value as a number but display leading zero.

    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    06-03-2008
    MS-Off Ver
    Excel 2007 (also have access to Excel 2000/2003)
    Posts
    368

    Re: Issues with Environ vba script

    Last one hit the nail on the head & Works a treat.

    Thank you all.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1