Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Junior Member
 
Posts: 10
Default Macros to convert Data into date format and then plot in graph

Hello

I have exported a data set to an excel file and i am trying to write a macros that will convert the data in the cell into a date format, and then use these dates to plot data points on a line graph. For example in my attachment, the first cell has data of 120304-000564. The part i need converted is the first half before the hyphen which is 120304. this should translate into 2012-03-04. The first two digits represents the year, followed by month and day. The second half of the numbers after the hyphen can just be removed.


once these numbers in column B are all converted into the proper date format, then i will need to activate a line graph creation from these data points. is this possible? thanks for any help!!
Attached Files
File Type: zip sampledata.zip (28.8 KB, 32 views)
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,872
Default Macros to convert Data into date format and then plot in graph

Hi,

Am Mon, 3 Mar 2014 21:09:34 +0000 schrieb taimysho0:

I have exported a data set to an excel file and i am trying to write a
macros that will convert the data in the cell into a date format, and
then use these dates to plot data points on a line graph. For example in
my attachment, the first cell has data of 120304-000564. The part i need
converted is the first half before the hyphen which is 120304. this
should translate into 2012-03-04. The first two digits represents the
year, followed by month and day. The second half of the numbers after
the hyphen can just be removed.


try:

Sub Test()
Dim LRow As Long

LRow = Cells(Rows.Count, 2).End(xlUp).Row
Range("B3:B" & LRow).TextToColumns Destination:=Range("B3"), _
DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, Other:=True, _
OtherChar:="-", FieldInfo:=Array(Array(1, 5), Array(2, 9)), _
TrailingMinusNumbers:=True
End Sub


Regards
Claus B.
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2
  #3   Report Post  
Junior Member
 
Posts: 10
Default

Quote:
Originally Posted by Claus Busch View Post
Hi,

Am Mon, 3 Mar 2014 21:09:34 +0000 schrieb taimysho0:

I have exported a data set to an excel file and i am trying to write a
macros that will convert the data in the cell into a date format, and
then use these dates to plot data points on a line graph. For example in
my attachment, the first cell has data of 120304-000564. The part i need
converted is the first half before the hyphen which is 120304. this
should translate into 2012-03-04. The first two digits represents the
year, followed by month and day. The second half of the numbers after
the hyphen can just be removed.


try:

Sub Test()
Dim LRow As Long

LRow = Cells(Rows.Count, 2).End(xlUp).Row
Range("B3:B" & LRow).TextToColumns Destination:=Range("B3"), _
DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, Other:=True, _
OtherChar:="-", FieldInfo:=Array(Array(1, 5), Array(2, 9)), _
TrailingMinusNumbers:=True
End Sub


Regards
Claus B.
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2
thanks so much for your help! now that i have these in date format, do you know how i can do a count of all dates that are the same so i can plot them in a graph? for example all dates that are 3/4/2012, count them together, and use that number as the data plot and the date of 3/4/12 as the x axis on the graph?
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,872
Default Macros to convert Data into date format and then plot in graph

Hi,

Am Tue, 4 Mar 2014 17:43:08 +0000 schrieb taimysho0:

now that i have these in date format, do
you know how i can do a count of all dates that are the same so i can
plot them in a graph?


in C3:
=COUNTIF(B:B,B3)
and copy down


Regards
Claus B.
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2
  #5   Report Post  
Junior Member
 
Posts: 10
Default

Quote:
Originally Posted by Claus Busch View Post
Hi,

Am Tue, 4 Mar 2014 17:43:08 +0000 schrieb taimysho0:

now that i have these in date format, do
you know how i can do a count of all dates that are the same so i can
plot them in a graph?


in C3:
=COUNTIF(B:B,B3)
and copy down


Regards
Claus B.
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2

thank you so much for your help! the last question is, in your date modify code above, how would i modify it so that the results displayed are always within the last 90 days? so for example anything older than 90 days gets deleted. thanks so much!


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,872
Default Macros to convert Data into date format and then plot in graph

Hi,

Am Tue, 4 Mar 2014 22:38:28 +0000 schrieb taimysho0:

the last question is, in your date
modify code above, how would i modify it so that the results displayed
are always within the last 90 days? so for example anything older than
90 days gets deleted. thanks so much!


you can filter your date for the last 90 days. The chart shows only the
values in the visible cells. So you can keep all your data.


Regards
Claus B.
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2
  #7   Report Post  
Junior Member
 
Posts: 10
Default

Quote:
Originally Posted by Claus Busch View Post
Hi,

Am Tue, 4 Mar 2014 22:38:28 +0000 schrieb taimysho0:

the last question is, in your date
modify code above, how would i modify it so that the results displayed
are always within the last 90 days? so for example anything older than
90 days gets deleted. thanks so much!


you can filter your date for the last 90 days. The chart shows only the
values in the visible cells. So you can keep all your data.


Regards
Claus B.
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2
ahh i see. thanks for that suggestion, however this would be a manual filter every time i want to filter this. my goal is to include all these manual steps in a macros so that when a user clicks a button, the raw data will be transformed to dates, and displaying only the last 90 days, and then from here, count the number of dates with same dates, and then create a graph from this data. everything else should be deleted and only graph appearing. thats the goal of the macros. im trying to include your code into the macros but having a hard time writing the code for the = last 90 days filter. thanks agian for any help!! :)
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,872
Default Macros to convert Data into date format and then plot in graph

Hi,

Am Wed, 5 Mar 2014 17:19:15 +0000 schrieb taimysho0:

my goal is to include all
these manual steps in a macros so that when a user clicks a button, the
raw data will be transformed to dates, and displaying only the last 90
days, and then from here, count the number of dates with same dates, and
then create a graph from this data. everything else should be deleted
and only graph appearing. thats the goal of the macros. im trying to
include your code into the macros but having a hard time writing the
code for the = last 90 days filter. thanks agian for any help!! :)


then create dynamic range names for x values and y values and create
with these names the chart. The dynamic names will always include the
last 90 days.
Please have a look:
https://onedrive.live.com/?cid=9378A...121822A3%21326
for "sampledata"


Regards
Claus B.
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
plot schedule-type data in graph, date and times as x & y axes weblun Charts and Charting in Excel 1 May 6th 09 09:30 AM
How to plot Date Ranges on Same Graph JJ Charts and Charting in Excel 2 April 7th 09 11:03 PM
Can't graph data with Date Format with hours BRB Excel Discussion (Misc queries) 2 August 13th 08 10:13 AM
How to make xy plot of date format data in both columns Pardeep Mohan Charts and Charting in Excel 1 August 30th 06 09:13 AM
How do I convert Dates from Text back to Date format using macros Frank Kabel Excel Programming 0 July 29th 04 03:40 PM


All times are GMT +1. The time now is 02:40 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"