+ Reply to Thread
Results 1 to 9 of 9

Fitting data into fields out of an irregular list

  1. #1
    Registered User
    Join Date
    12-16-2013
    Location
    Chicago
    MS-Off Ver
    Excel 2010
    Posts
    8

    Fitting data into fields out of an irregular list

    Hi friends,

    I have a list of data (names, employee IDs, work location, etc) in a single column in a tab that I would like to bring into a particular format. Each record is separated by a blank row. Essentially I'm trying to capture only 3 fields for each record- name, employee ID and location. However as in the following screenshot, I sometimes have less than 3 fields or sometimes more than 3 fields available for each record.

    Picture1.jpg

    I would like to write a macro whereby each record has exactly 3 fields even if they are blank. This would mean inserting any blank rows as needed to make each record have 3 fields; or deleting any extra fields after the 3rd row in a record.

    I also want to bring this into a 3-columnar format until the list is finished (when there are no more records). I would appreciate any help with this. I have attached a sample worksheet.


    The data exists in the 'Staging' tab, and the 3-columnar format exists in the 'Output' tab, where I would like to have the final output.

    Thanks!
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor
    Join Date
    01-19-2010
    Location
    Melbourne Australia
    MS-Off Ver
    latest is Excel 2016. have older versions
    Posts
    624

    Re: Fitting data into fields out of an irregular list

    Hi vijaijohn,
    just a quick question, how important is altering the staging tab to be a standard format? Will this be used or, as the name implies, simply be a working area with the actual Output tab being the deliverable?
    Jmac1947

  3. #3
    Registered User
    Join Date
    12-16-2013
    Location
    Chicago
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Fitting data into fields out of an irregular list

    Hi Jmac1947,

    Thanks for replying.

    The Staging tab is just a working area. I can leave it blank after the clean data is moved to Output. I found a long-winded workaround involving 4 separate Macros, but I can't seem to loop the actions until the end of the list. It would help if the process could be automated.

    Briefly, I did this:

    Macro1 returned values through column B as to whether a corresponding cell in column A was blank or not. If it was blank the cell in column B would be "BLANK". This Macro also copied and pasted Column B with "values" only, so the returned value actually read "BLANK" instead of a formula.

    Macro2 copied and pasted the first three rows in Column A in the Staging tab into the columns in Output. There are at least 2 non-empty rows, so in the worst case, the 3rd column in Output would be blank- which is okay.

    Macro3 searched for the first instance from row 1 in Staging where it found the word "BLANK" and deleted all rows above it and including it. I wrote another Macro (Macro3b) to replace the first 2 rows which are header rows. Macro3 cleaned up after itself by calling this macro.

    I assigned a short cut key to Macro3 and I keep applying this until the end of the list. As I said if I could automate this, it would be great.



    VJ

  4. #4
    Valued Forum Contributor
    Join Date
    01-19-2010
    Location
    Melbourne Australia
    MS-Off Ver
    latest is Excel 2016. have older versions
    Posts
    624

    Re: Fitting data into fields out of an irregular list

    Hi vj,

    OK, I am having a play with it now. As a master of scope creep (when I should be resisting it ) I would probably split the employee name into two cols in the output tab to allow easy sorting into different orders if required.

    Another question, is it safe to assume that there will always be an employee name row at a minimum?
    Jmac1947
    Last edited by jmac1947; 01-06-2014 at 10:09 PM.

  5. #5
    Registered User
    Join Date
    12-16-2013
    Location
    Chicago
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Fitting data into fields out of an irregular list

    Hi Jmac1947, Yes- there would be at least a name row and an employee ID row. So at least 2 rows in a record.

    You're right about splitting the name. There is a long cleanup involving all fields after I get through this step

    VJ

  6. #6
    Valued Forum Contributor
    Join Date
    01-19-2010
    Location
    Melbourne Australia
    MS-Off Ver
    latest is Excel 2016. have older versions
    Posts
    624

    Re: Fitting data into fields out of an irregular list

    Hello vj,

    If the attachment works then you can take a look at the macro in the attached spreadsheet.

    It appears to work for excel 2010 at least.

    You will see that I am an old fashioned programmer who takes it one easy step at a time (and am in complete awe of a number of people on this forum who do amazing things with very complex statements). I didnt do any real error handling, just concentrated on getting a simple solution.

    Hope this helps your task

    jmac1947
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    12-16-2013
    Location
    Chicago
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Fitting data into fields out of an irregular list

    Hi JMAC, many thanks for this. The last name omits a letter at the end, which is the only issue. But it solves my problem of automating the process without having to apply the short cut key. Once again, thanks much!!

  8. #8
    Valued Forum Contributor
    Join Date
    01-19-2010
    Location
    Melbourne Australia
    MS-Off Ver
    latest is Excel 2016. have older versions
    Posts
    624

    Re: Fitting data into fields out of an irregular list

    Hi vj,

    alter one line only
    ab = cell_length + 1 - aa
    that is probably the easiest way to fix the issue
    glad to help

  9. #9
    Registered User
    Join Date
    12-16-2013
    Location
    Chicago
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Fitting data into fields out of an irregular list

    Thanks! It works perfectly now!

+ 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. Excel 2007 : How to do a Data Fitting?
    By Nokia N93 in forum Excel General
    Replies: 3
    Last Post: 12-20-2011, 03:07 AM
  2. Appending data from linked txt file: Irregular fields...
    By jcbrat in forum Access Programming / VBA / Macros
    Replies: 0
    Last Post: 12-12-2011, 05:46 PM
  3. remove irregular count of 0 from a list of numbers
    By sa02000 in forum Excel General
    Replies: 3
    Last Post: 04-12-2011, 07:49 PM
  4. Fitting data into worksheet
    By danison in forum Excel General
    Replies: 6
    Last Post: 02-12-2011, 10:49 PM
  5. sorting slightly irregular date fields in a pivot table
    By tdoggette in forum Excel General
    Replies: 1
    Last Post: 07-21-2009, 08:56 AM

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