+ Reply to Thread
Results 1 to 4 of 4

VBA -- Mapping Time Category from Time values

Hybrid View

Vinod Krishna.C VBA -- Mapping Time Category... 09-26-2018, 08:29 AM
AlphaFrog Re: VBA -- Mapping Time... 09-26-2018, 08:43 AM
AlphaFrog Re: VBA -- Mapping Time... 09-26-2018, 09:09 AM
Vinod Krishna.C Re: VBA -- Mapping Time... 09-26-2018, 11:03 AM
  1. #1
    Forum Contributor
    Join Date
    06-05-2013
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2016
    Posts
    110

    VBA -- Mapping Time Category from Time values

    Dear all,

    I'm trying to write a code to map time values to a specific Time Category, as shown below, but in vain.

    Time Time Category
    20:05:00 8 PM to 9 PM
    11:59:00 11 AM to 12 PM

    I've attached the code. Perhaps, it's something to do with formatting.

    Appreciate any help on the same.

    Thanks,
    Vinod Krishna
    Attached Files Attached Files

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,653

    Re: VBA -- Mapping Time Category from Time values

    Try this formula

    Formula: copy to clipboard
    =TEXT(A2,"h AM/PM to ") & TEXT(A2+TIME(1,0,0),"h AM/PM")
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,653

    Re: VBA -- Mapping Time Category from Time values

    Or this VBA code

        Do Until IsEmpty(ActiveCell)
            
            ActiveCell.Offset(, 2).Value = Format(CDate(ActiveCell.Value), "h AM/PM to ") & Format(CDate(ActiveCell.Value) + TimeSerial(1, 0, 0), "h AM/PM")
            
            ActiveCell.Offset(1, 0).Select
            
        Loop

  4. #4
    Forum Contributor
    Join Date
    06-05-2013
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2016
    Posts
    110

    Re: VBA -- Mapping Time Category from Time values

    Thanks a lot AlphaFrog. Most efficient code and works like a charm

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Time Category Formular
    By brandon_jrose in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 11-20-2016, 05:39 AM
  2. [SOLVED] Mapping Data between 2 sheets based on iteration time - VBA
    By spiwere in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 07-21-2015, 12:30 PM
  3. Replies: 1
    Last Post: 05-13-2015, 07:17 AM
  4. Excel 2003 - Date and Time Mapping - need help
    By SunRay in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-09-2014, 03:29 PM
  5. Time mapping macro - Needed for different worksheets
    By rajudhl in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-17-2014, 01:55 PM
  6. [SOLVED] Userform Tally by time and category.
    By Hett in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-25-2013, 04:13 PM
  7. compare time values - current time with time in cell range?
    By wyattea in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-13-2013, 11:28 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1