Solved

Find Value and Replace

Posted on 2013-06-10
3
273 Views
Last Modified: 2013-06-10
Hello, needing a macro to perform the following:

I have a sheet that ingests data from the web and then I parse out the data via a macro.  What I need is in cell BG1, there will be four possible values in this cell, 00Z, 06Z, 12Z, 18Z.  Each one is a time reference like 18Z is 18 UTC time.  Based on which value is in BG1, I need make BE2=BG1, then add one hour and put that vlaue in BF 2, add another hour and put that value in BG 2.

I need this in a macro format as I have to clear the data often and the formulas will get deleted.
Sample1.xlsx
0
Comment
Question by:sandramac
  • 2
3 Comments
 
LVL 22

Accepted Solution

by:
Flyster earned 500 total points
ID: 39236265
This macro should get you the results you want:
Sub FormatTime()
Dim i, x As Integer

i = Left(Range("BG1").Value, 2)
Range("BE2").Select
For x = 1 To 19
  If i > 23 Then
    i = 0
  End If
    ActiveCell.Value = i
    i = i + 1
    ActiveCell.Offset(0, 1).Select
Next x

End Sub

Open in new window

Flyster
0
 

Author Closing Comment

by:sandramac
ID: 39236302
Awesome, thank you that is what I needed.
0
 
LVL 22

Expert Comment

by:Flyster
ID: 39236392
Glad I could help!
0

Featured Post

Industry Leaders: 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

Having trouble getting your hands on Dynamics 365 Field Service or Project Service trial? Worry No More!!!
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

679 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