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...
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...