Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Excel Search Time column return time value and value

Posted on 2016-08-04
5
Medium Priority
?
38 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:IT SSM
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 53

Accepted Solution

by:
Rgonzo1971 earned 1600 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 18

Assisted Solution

by:xtermie
xtermie earned 400 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 53

Assisted Solution

by:Rgonzo1971
Rgonzo1971 earned 1600 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:IT SSM
ID: 41743551
Great solution can be modified easily to suit other solutions great job. Rgonzo
0
 
LVL 18

Expert Comment

by:xtermie
ID: 41772809
Best solution by Rgonzo
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article describes a serious pitfall that can happen when deleting shapes using VBA.
After seeing numerous questions for Dynamic Data Validation I notice that most have used Visual Basic to solve the problem. This suggestion is purely formula based and can be used in multiple rows.
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.

618 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