VBA inputbox Greater Than or Equal to for Date, UTC Date Time Now Format

vbanewbie68

Board Regular
Joined
Oct 16, 2021
Messages
171
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
Hello :)

Please see my screenshots below.

I enter a date, using this greater than or equal to this 2021-12-07T14:03:36 UTC. I get blank cells.

I am not sure what went wrong with the codes?

The data can be either big or small. I get it weekly data.

Hope the everything makes sense?

Thank you

Regards

Vbanewbie68

1658500250219.png


1658500328942.png
 
You'll need to adjust the code a bit, I think - namely, the range of the cells that you want to convert into dates (currently it's looking at cells G2:G10). You should also play with the date pattern until you get it working just the way you want it to.

Assuming that the cell to be processed contains data like 2022-04-04T10:10:10 UTC - it should retain the time data as well. If you want to change the formatting in the actual cells, you should do that by adjusting the custom formatting options (press ctrl 1).

Hope that helps.
 
Upvote 0

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
This might help you process the data into dates before filtering it:

VBA Code:
Sub ProcessCells()
   
    Const DATEPATTERN = "dd/mm/yyyy"
    Const TARGETRANGE = "G2:G10"
   
    Dim CurrentCell     As Range
    Dim CurrentDate     As String
    Dim FormattedDate   As Date
    Dim TempDate        As Variant
       
    For Each CurrentCell In Range(TARGETRANGE)
        CurrentDate = VBA.Replace(CurrentCell.Value, "UTC", "")
        TempDate = Split(Application.Trim(CurrentDate), "T")
        FormattedDate = CDate(Format(TempDate(0), DATEPATTERN)) + CDate(TempDate(1))
        CurrentCell.Value = FormattedDate
    Next
   
End Sub



Not sure what went wrong as below.


1658511422686.png
 
Upvote 0
I got it working now :) even though I change this DATEPATTERN= "MM/DD/YYYY and that works with this date 07/12/2021

Also how to add code as I get a large data and sometime small data. How do I add Range.End Xldown code?

There is a bug I can't move it to a new workbook. What went wrong with my code? Should it be in public?

1658517623937.png


1658517826885.png
 
Upvote 0
Hi
Thank you for your help and your time writing codes to solve my issue, I really appreciate it. I have managed to figure out the other issue I mentioned earlier.
Again thank you!
Best regards
V
 
Upvote 0
Sorry, I meant to respond, but i was busy yesterday. I suspect the problem was that you hadn't defined the final workbook and worksheet variables, is that right?
 
Upvote 0
Move it into a new Workbook is no problem. Just an issue with end. Xldown codes that I am struggling with because data can be large or small.
 
Upvote 0

Forum statistics

Threads
1,215,514
Messages
6,125,269
Members
449,219
Latest member
daynle

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top