+ Reply to Thread
Results 1 to 7 of 7

Adjusting information with VBA

  1. #1
    Registered User
    Join Date
    05-14-2010
    Location
    England
    MS-Off Ver
    Excel 365
    Posts
    14

    Adjusting information with VBA

    Hi all

    Here I have a sample of a large file I got for people taking a certain class.

    Name Class 1 Class 2 Class 3 Class 4 Class 5
    George MO1 TU3
    Amy MO2 TU4 WE3
    Michael MO7
    MOrk MO8 WE1
    Eric MO16
    James MO17 TU3 FI1 SA1 MO2
    Paul MO18

    Now what I would like excel to do is that for example for Amy (she takes 3 classes) 2 extra rows are inserted and copied so that the table looks like this:

    Name Class 1 Class 2 Class 3 Class 4 Class 5
    George MO1 TU3
    Amy MO2 TU4 WE3
    Amy TU4 TU4 WE3
    Amy WE3 TU4 WE3
    Michael MO7
    MOrk MO8 WE1
    Eric MO16
    James MO17 TU3 FI1 SA1 MO2
    Paul MO18

    Like this I can eventually delete the other classes and only keep column class 1.

    Is it possible to let excel run through the file, see how much classes a person takes and then put these in the first column?

    Thanks in advance

  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: Problem adjusting information with VBA

    To best describe or illustrate your problem you would be better off attaching a dummy workbook, the workbook should contain the same structure and some dummy data of the same type as the type you have in your real workbook - so, if a cell contains numbers & letters in this format abc-123 then that should be reflected in the dummy workbook.

    If needed supply a before and after sheet in the workbook so the person helping you can see what you are trying to achieve.

    Doing this will ensure you get the result you need!
    Hope that helps.

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

    Free DataBaseForm example

  3. #3
    Registered User
    Join Date
    05-14-2010
    Location
    England
    MS-Off Ver
    Excel 365
    Posts
    14

    Re: Problem adjusting information with VBA

    See file attached. I already tried some things in vba but its not working properly. I think it can be more efficient
    Attached Files Attached Files
    Last edited by tos; 08-13-2011 at 12:11 PM.

  4. #4
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Problem adjusting information with VBA

    Hi tos
    This code is in the attached
    Please Login or Register  to view this content.
    Let me know of issues.
    Attached Files Attached Files
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  5. #5
    Registered User
    Join Date
    05-14-2010
    Location
    England
    MS-Off Ver
    Excel 365
    Posts
    14

    Re: Problem adjusting information with VBA

    Thanks! that works fine. Could you confirm me if I was close with what I wrote?
    Is it possible with "if" functions?

  6. #6
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Problem adjusting information with VBA

    hi, tos, alternative much faster option, run code "test"
    Attached Files Attached Files

  7. #7
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Problem adjusting information with VBA

    Hi tos

    This is what I envision the code would look like using "If" statements
    Please Login or Register  to view this content.
    Of course you'll still need to move the "Class" stuff around but your original code didn't do that so I'll leave you to play with an approach to do that.

+ 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