Solved

Excel Search Time column return time value and value

Posted on 2016-08-04
5
29 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 48

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 48

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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

INDEX and MATCH can be used to great effect to replace HLOOKUP and VLOOKUP as it does not have the limitation of needing the data to be sorted so that the reference value is in the first column or row. It also has the ability to perform a bi-directi…
How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

743 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

12 Experts available now in Live!

Get 1:1 Help Now