+ Reply to Thread
Results 1 to 8 of 8

Insert rows and enter data based on day and time criteria

  1. #1
    Registered User
    Join Date
    10-15-2013
    Location
    Seattle
    MS-Off Ver
    Excel 2010
    Posts
    5

    Insert rows and enter data based on day and time criteria

    Hi to one and all.

    The problem I am experiencing stems from the fact that my collected data often has missing hours, as seen in the attached jpeg. What I need to do is insert a row(s) and enter "dummy" data so that all 24 hours of the day are represented. I have tried unsuccessfully to adapt code that I have found on the web (I am a beginner at vba coding). I have 3 columns of data and the data I collect is always on Tuesday, Wednesday, and Thursday. The Data is always in chronological order (minus the missing hours). The number of rows for any of the days varies from week to week. The data always starts in cell A1. Any help would be greatly appreciated.
    Attached Images Attached Images

  2. #2
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: Insert rows and enter data based on day and time criteria

    no jpg please, but excel file for code testing
    If solved remember to mark Thread as solved

  3. #3
    Registered User
    Join Date
    10-15-2013
    Location
    Seattle
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Insert rows and enter data based on day and time criteria

    Thank you patel45 for responding to my post. I have attached a sample excel file. As I mentioned, I have tried revising codes and macros, but to no avail. Your help and interest is greatly appreciated.
    Attached Files Attached Files

  4. #4
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: Insert rows and enter data based on day and time criteria

    try this
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    10-15-2013
    Location
    Seattle
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Insert rows and enter data based on day and time criteria

    I believe my initial explanation was too vague and not properly informative. To clarify; I need code that will scan the hour column and determine that there has been a skip of one or more hours (hours are in 24 hr. time) in each of the days. For instance, as can be seen from the excel example for 10/1/2013, the hours 0:00:00, 1:00:00, 3:00:00, 4:00:00, 10:00:00, 17:00:00, and 21:00:00 are missing. The code should insert these missing times in their respective chronological order. Also, it needs to include the date and a dummy phase (it's always 0). I tried the code. It did insert rows, although they were blank and sometimes it inserted more than needed. I have concluded after hours of attempting to modify other codes, that I am simply in over my head on this. Currenlty, I have to go through 1000's of rows of data each week and manually insert the "dummy" data. It's very tedious and time consuming, so any and all help is really appreciated.

  6. #6
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: Insert rows and enter data based on day and time criteria

    can you attach a sample file with data and desired result ?

  7. #7
    Registered User
    Join Date
    10-15-2013
    Location
    Seattle
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Insert rows and enter data based on day and time criteria

    I believe, in order to make the spreadsheets comprehensible, a little background would help. I have attached both a sample .txt file, a sample spreadsheet and a final product spreadsheet. Data from the .txt file (the sample has been shortened to make the 100k limit) is copied and pasted into cell A1 on the CSV tab of the spreadsheet. Pressing the Format and Transfer Data button automatically separates the text data, deletes unneeded columns and leaves columns with dates, time, and phase and then copies and pastes the formatted data into cell B2 on the Data tab. (A formula in the "A" column generates the day from the date). The problem that ultimately arises occurs when any hours are not represented by data causing the pivot tables and graphs to show incorrectly (all hours must show on the graph even if there is no data). The graphs are the ultimate product as seen in the second spreadsheet. Perhaps my approach is flawed, but it's the best I have been able to do so far. Again, I sincerly appreciate the time you are taking to help me out.
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    10-15-2013
    Location
    Seattle
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Insert rows and enter data based on day and time criteria

    I have solved my dilemma by using the vlookup function. Thanks patel45 for looking at and considering solutions for the problem I posed.

+ 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. Insert rows and enter data in blank cells.
    By jscalem in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-22-2013, 06:47 AM
  2. Replies: 1
    Last Post: 01-30-2013, 12:12 PM
  3. Replies: 1
    Last Post: 12-27-2012, 02:43 PM
  4. Delete Rows Based on Time criteria
    By Roelandu in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-26-2012, 08:07 AM
  5. [SOLVED] Excel 07 - Macro to insert rows based on criteria
    By smic in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-18-2012, 09:58 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