dates and csv files

Patricia0923

New Member
Joined
Mar 18, 2014
Messages
25
Hope you can help me get started.

Here's the question...

I have created a spreadsheet called Matrix Test.
I have it set so that when a user opens it they are to input a date in cell C1

Private Sub Worksheet_Change(ByVal Target As Range)


If Target.Address = "$C$1" Then
If IsDate(Range("C1").Value) Then
Application.Run "OpenR2D2"
End If
End If
End Sub

Once that date is entered, VBA code runs to open a file on a virtual drive... ChDir "P:\Data"

In this case the file is a csv file named projections
Workbooks.Open Filename:= "P:\Data\projections.csv"

Next I need to scan the worksheet for a series of dates going back six weeks. For example,
Date1=($C$1)
Date2=($C$1)-7
Date3=($C$1)-14
Date4=($C$1)-21
Date5=($C$1)-28
Date6=($C$1)-35

The first issue I need to address is that the dates (found in Column A) on the projections csv file are formatted like this '03/06/2013' which means that Excel does not see those as dates, but as text, right? So how do I write code to find these values?

The next issue is that once I have found the dates, I have to find in Column B the corresponding times (11,12,13,14) that are written as follows '11:00', '12:00', '13:00', '14:00'. Of course once that's done I want to get the value for
column D "Projected CCs" and then add all four of those numbers to get the value to place in my Matrix Text spreadsheet.

So what do think? Where do I start?
I thought maybe use the Find method, but I'm not really familiar with it.
Or maybe Select Case.

I'm still very new to VBA...
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".

Forum statistics

Threads
1,215,473
Messages
6,125,018
Members
449,203
Latest member
tungnmqn90

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