+ Reply to Thread
Results 1 to 3 of 3

VBA Adding Prefix characters to variable

  1. #1
    Registered User
    Join Date
    12-17-2019
    Location
    Leeds, UK
    MS-Off Ver
    365
    Posts
    61

    Question VBA Adding Prefix characters to variable

    Hi all,

    The following is an extract of VBA code I have which reads and stores a cell value, and then the variable SiteNo takes the first 5 characters. These two variables are then written into Master_Sheet:
    Please Login or Register  to view this content.
    This works fine, but I'd like the SiteNo value entered into Master_Sheet to have the digits "4500" before it.
    So, say SiteNo was 10949, I'd like the value in Master_Sheet to be 450010949.

    This must be very straight forward but I'm having no luck with either of the following:
    Please Login or Register  to view this content.
    Any help would be great, thanks!

  2. #2
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,915

    Re: VBA Adding Prefix characters to variable

    What exactly does "no luck" mean? Either of those should work.
    Rory

  3. #3
    Registered User
    Join Date
    12-17-2019
    Location
    Leeds, UK
    MS-Off Ver
    365
    Posts
    61

    Re: VBA Adding Prefix characters to variable

    Hi Rory, thanks for reaching out. I've just realised that VBA didn't like that the integer value of SiteNo was now a string of "4500" and the integer. Changing Dim SiteNo As Integer to String has fixed the problem! Thanks for your time

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. adding prefix to numbers
    By dph150 in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 04-08-2011, 02:50 PM
  2. Adding prefix to a name
    By [email protected] in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 06-28-2010, 03:08 AM
  3. Adding prefix to column of filenames
    By uglyduck in forum Excel General
    Replies: 4
    Last Post: 02-05-2010, 09:48 AM
  4. Adding a prefix to a rane in a column
    By nscherneck in forum Excel General
    Replies: 4
    Last Post: 12-03-2009, 05:33 PM
  5. adding prefix and suffix macro
    By justix in forum Excel - New Users/Basics
    Replies: 5
    Last Post: 01-10-2007, 06:14 AM
  6. adding a prefix to cells
    By PaulPA in forum Excel General
    Replies: 5
    Last Post: 12-07-2006, 03:48 PM
  7. adding a prefix to cells
    By PaulPA in forum Excel General
    Replies: 2
    Last Post: 07-17-2006, 03:28 PM
  8. Adding zero prefix to no's
    By Cheryl W in forum Excel General
    Replies: 4
    Last Post: 05-30-2005, 10:05 PM

Tags for this Thread

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