Solved

Find Value and Replace

Posted on 2013-06-10
3
270 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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

In this article we discuss how to recover the missing Outlook 2011 for Mac data like Emails and Contacts manually.
Outlook Free & Paid Tools
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

773 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