+ Reply to Thread
Results 1 to 5 of 5

Auto insert value in a column

  1. #1
    Forum Contributor
    Join Date
    08-01-2007
    Posts
    110

    Auto insert value in a column

    Hi there Everyone! I have the following problem. I have an excel sheet where I gather information about companies. There are two columns involved in my problem. Column "D" and column "E". In column "D" I put the country code (example: DE for Germany, GB for England and so on..) In column "E" I put a number (for example: 45786521). What I would like Excel to do is to autoinsert the value of the column "D" before the numbers I have written in column "E". For example if in Row 12 column "D" is GB. And then I write the number 555888777 in column "E", then after the number is written and I hit Enter I would like column "E" to look this way: GB555888777. So the GB (value of the column "D") is inserted at the beginnig of the number I just wrote in column "E". How can that be done?

    P.S.:I know that there is a possibility to add the values of these two columns in another column, but as there are far too many columns in the worksheet I would not like to add an extra column just for this.

    Thank you in advance for your help, and have a nice weekend!
    Last edited by hunsnowboarder; 11-04-2008 at 01:49 PM.

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    12,499
    This can be done with VBA(macro)

    Place this code in the worksheet module,
    Go to this link to find out where that is:http://www.contextures.com/xlvba01.html#Worksheet

    Copy and paste this code there
    Please Login or Register  to view this content.
    When you change a value in column E, the vba code kicks in

  3. #3
    Forum Contributor
    Join Date
    08-01-2007
    Posts
    110
    Woow! Thanks a lot Dave..it is working! Thank you, thank you!

  4. #4
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    hunsnowboarder,

    If you're problem is solved then please mark it as solved

    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  5. #5
    Forum Contributor
    Join Date
    08-01-2007
    Posts
    110
    Well..I just realised that this solution is only half solution..
    Example: let us say I have value AT in column D. Then I add a number (lets say 11111) to column E and then (thanks to the VBA code) I get the value AT11111 in column E. Till now everything is ok. But then if I change the value in column D (lets say from AT to XY) then column E does not update its value (so column E has still the AT11111 value..but it should have XY11111). Can somenone help me with this update cell value problem?

    Thank you in advance!

+ 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