+ Reply to Thread
Results 1 to 5 of 5

Data Population Macro based on date

  1. #1
    Registered User
    Join Date
    09-27-2011
    Location
    cah
    MS-Off Ver
    Excel 2003
    Posts
    3

    Data Population Macro based on date

    My excel sheet has three columns and tracks fluid level in a pipe:
    A. Location
    B. Date
    C. Fluid Level

    I am building an excel sheet to export the above data into a different database. I have two problems:

    1. The data will be entered as it is collected at different locations on different dates but needs to be sorted by location. I think I could use a sort function to do this.
    2. 2.The second problem I have is that I need data for every day but the data entry for a given location doesn't occur daily. The data does however, remain constant between dates. I want to duplicate the data between entries so that there is data for each date.

    The sheet looks like this

    Location | Date | Fluid Level
    A | 09/01/2011 | 85
    C | 09/04/2011 | 78
    D | 09/05/2011 | 40
    A | 09/10/2011 | 50

    I would like it to look like
    Location | Date | Fluid Level
    A | 09/01/2011 | 85
    A | 09/2/2011 | 85
    .. | .. | ..
    .. | .. | ..
    A | 09/09/2011 | 85
    A | 09/10/2011 | 50
    C | 09/04/2011 | 78
    D | 09/05/2011 | 40

    Thanks

  2. #2
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591

    Re: Data Population Macro based on date

    Hi

    See how this goes.

    Please Login or Register  to view this content.
    rylo

  3. #3
    Registered User
    Join Date
    09-27-2011
    Location
    cah
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Data Population Macro based on date

    Code works perfectly. Thanks a lot for the help.

    I don't understand this part of the macro though could you please explain:

    For i = 2 To Cells(Rows.Count, 1).End(xlUp).Row.

    Cheers

  4. #4
    Registered User
    Join Date
    09-27-2011
    Location
    cah
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Data Population Macro based on date

    Also how does this work? I am having trouble understanding the offset.

    outrow = Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row

  5. #5
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591

    Re: Data Population Macro based on date

    Hi

    Please Login or Register  to view this content.
    : this is effectively going to the last cell in the column (in this case column 1) and doing a ctrl up, and then determining the row of the cell that you have selected. It determines the last used cell in the column.

    Please Login or Register  to view this content.
    This does the same as the above command, but once it has found the last cell, it steps down one cell, then puts the row into the variable outrow. It effectively determines the next blank row in the column to receive data.

    HTH

    rylo

+ 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