+ Reply to Thread
Results 1 to 6 of 6

Splitting the contents of a cell

  1. #1
    Registered User
    Join Date
    10-23-2006
    Posts
    11

    Splitting the contents of a cell

    Hi guys, im looking for a little help with a problem i have here. Im importing data into a spreadsheet and in each cell in one collum there are two pieces of data that need to be split.

    The cell length is 17 characters long, with the firts piece of data being 6 digits and the second set of data being 11.

    What i want to do is to run a macro that will take my selection of cells and split them into 2 seperate cells. So if A1 to A10 would be split into B1 to B10 for the first 6 digits and C1 to C10 for the second set of digits (11 characters long).

    Is it possible?

    My other question is regrading if statements. what i want to do is as follows:

    If cell selection = 1 then cell selection should now show as "mark"
    If cell selection = 2 then cell selection should now show as "Dave"

    again is this possible? Thanks alot for the help, its already helped me do so much

  2. #2
    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
    Hi,

    Does it have to be VBA code.

    You can use formulas for all this

    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 !!!

  3. #3
    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
    Hi,

    Formula's for splitting the cells

    First 7
    =LEFT(A1,7)

    Last 7
    =RIGHT(A1,11)



    Some code to change a say a ref eg B3 to Mark. It's an event Macro so right click the sheet your using and select view code and then paste

    Please Login or Register  to view this content.
    VBA Noob

  4. #4
    Registered User
    Join Date
    10-23-2006
    Posts
    11
    Thanks for the help, ive modified the code slightley and its working great. However one thing id like to know is if its possible to remove a digit from right hand side of a cell on only one collum.

    For example im highlighting all the cells in the workbook and running a macro where i want all the cells in collum A to have a digit removed at the right hand side of there cell. I.e 3001 becomes 300.

    Is it possible to make this collum specific using VB?

  5. #5
    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
    Hi,

    Try this code

    Please Login or Register  to view this content.
    VBA Noob

  6. #6
    Registered User
    Join Date
    04-14-2011
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    1

    Re: Splitting the contents of a cell

    Hi,

    In A1 I have cell data like this "h1/h2/h3/h1" from this i need to takeoff the unique values and need to display "h2/h3" in A2.

    Any clues. Thanks in advance.

    HS

+ 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