Solved

Excel Search Time column return time value and value

Posted on 2016-08-04
5
31 Views
Last Modified: 2016-08-27
I have an excel spreadsheet with three columns
A Time column
A Id Column
A value column

There is a row of data generated every second.

I would like some VBA code that will scan a time column for whole minutes and copy the time value, ID and value to new columns.
In the attached file the times will be minutes 1 to 10 on a full data set this would occur across 24 hours.
samplebook.xlsx
0
Comment
Question by:OST-IS
  • 2
  • 2
5 Comments
 
LVL 49

Accepted Solution

by:
Rgonzo1971 earned 400 total points (awarded by participants)
ID: 41742347
Hi,

pls try
Sub macro()
Rw = 1
For Each c In Range(Range("A1"), Range("A" & Rows.Count).End(xlUp))
    If TimeValue(c.Text) = TimeSerial(Hour(c), Minute(c), 0) Then
        Sheets("Sheet2").Range("A" & Rw) = c
        Sheets("Sheet2").Range("A" & Rw).NumberFormat = c.NumberFormat
        Sheets("Sheet2").Range("B" & Rw) = c.Offset(, 1)
        Sheets("Sheet2").Range("C" & Rw) = c.Offset(, 2)
        Rw = Rw + 1
    End If
Next
End Sub

Open in new window

Regards
0
 
LVL 17

Assisted Solution

by:xtermie
xtermie earned 100 total points (awarded by participants)
ID: 41742352
Hey OST-IS...Don't think you need VBA code, you can do this in a second sheet with functions
Check the sample attached
Result spreadsheet gets minute form Time column and then fills in the ID and value to new columns in the Result spreadsheet.  All you have to do is copy down the formulas.

Hope this helps
samplebook_example.xlsx
0
 
LVL 49

Assisted Solution

by:Rgonzo1971
Rgonzo1971 earned 400 total points (awarded by participants)
ID: 41742354
In the same Sheet
Sub macro()
Rw = 1
For Each c In Range(Range("A1"), Range("A" & Rows.Count).End(xlUp))
    If TimeValue(c.Text) = TimeSerial(Hour(c), Minute(c), 0) Then
        Range("F" & Rw) = c
        Range("F" & Rw).NumberFormat = c.NumberFormat
        Range("G" & Rw) = c.Offset(, 1)
        Range("H" & Rw) = c.Offset(, 2)
        Rw = Rw + 1
    End If
Next
End Sub

Open in new window

2
 

Author Comment

by:OST-IS
ID: 41743551
Great solution can be modified easily to suit other solutions great job. Rgonzo
0
 
LVL 17

Expert Comment

by:xtermie
ID: 41772809
Best solution by Rgonzo
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Improved? Move/Copy Add-in Replacement - How to avoid the annoying, “A formula or sheet you want to move or copy contains the name XXX, which already exists on the destination worksheet.” David Miller (dlmille)  It was one of those days… I wa…
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now