Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Converting weekly price data into daily (5 days of the week) format

I have a data file that looks like this.
26-Jan-68 1.02088 1.02088 1.02088 1.02088
2-Feb-68 1.01608 1.01608 1.01608 1.01608
9-Feb-68 1.01577 1.01577 1.01577 1.01577
16-Feb-68 1.01425 1.01425 1.01425 1.01425
..........

The current date fall on FRI. I want to add new rows with dates for
the following MoTuWeTh and copy the data from the last record into new
rows. In this example I will need to add 4 rows between 26-Jan-68 and
2-Feb-68, append dates that correspond to MoTuWeTh following 26-
Jan-68, and copy the data for 26-Jan-68 into these new rows. I need to
do this for all rows (which ends on current week--lots of rows to do
manually). Any help will be appreciated.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Converting weekly price data into daily (5 days of the week) format

On Feb 7, 9:19*pm, Sajjad Qureshi wrote:
I have a data file that looks like this.
26-Jan-68 * * * 1.02088 1.02088 1.02088 1.02088
2-Feb-68 * * * *1.01608 1.01608 1.01608 1.01608
9-Feb-68 * * * *1.01577 1.01577 1.01577 1.01577
16-Feb-68 * * * 1.01425 1.01425 1.01425 1.01425
.........

The current date fall on FRI. I want to add new rows with dates for
the following MoTuWeTh and copy the data from the last record into new
rows. In this example I will need to add 4 rows between 26-Jan-68 and
2-Feb-68, append dates that correspond to MoTuWeTh following 26-
Jan-68, and copy the data for 26-Jan-68 into these new rows. I need to
do this for all rows (which ends on current week--lots of rows to do
manually). Any help will be appreciated.


here is a vba as your starting point:

Sub copydate()
Dim dt As Range, c As Range
Dim dtArray() As Variant
Dim i As Integer, j As Integer

Set dt = Range([a1], [a1].End(xlDown))
ReDim dtArray(1 To dt.Rows.Count * 5, 1 To 5)

i = 1
For Each c In dt
For j = 0 To 4
dtArray(i + j, 1) = c.Value + j
dtArray(i + j, 2) = c.Offset(0, 1)
dtArray(i + j, 3) = c.Offset(0, 2)
dtArray(i + j, 4) = c.Offset(0, 3)
dtArray(i + j, 5) = c.Offset(0, 4)
Next
i = i + 5
Next

Dim target As Range
Set target = [h1] ' change this to where you want the new data
to be copied
target.Resize(dt.Rows.Count * 5, 5) = dtArray
End Sub
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,522
Default Converting weekly price data into daily (5 days of the week) format

Or

Sub insertrowsifFRIDAY()
For i = Cells(Rows.Count, 1). _
End(xlUp).Row To 1 Step -1
If Format(Cells(i, 1), "ddd") = "Fri" Then
Rows(i).Copy
Rows(i + 1).Resize(4).Insert
Cells(i + 1, 1) = Cells(i, 1) + 3
Cells(i + 1, 1).AutoFill _
Destination:=Cells(i + 1, 1).Resize(4)
'MsgBox i
End If
Next i
End Sub


On Feb 7, 9:23*pm, reza wrote:
On Feb 7, 9:19*pm, Sajjad Qureshi wrote:

I have a data file that looks like this.
26-Jan-68 * * * 1.02088 1.02088 1.02088 1.02088
2-Feb-68 * * * *1.01608 1.01608 1.01608 1.01608
9-Feb-68 * * * *1.01577 1.01577 1.01577 1.01577
16-Feb-68 * * * 1.01425 1.01425 1.01425 1.01425
.........


The current date fall on FRI. I want to add new rows with dates for
the following MoTuWeTh and copy the data from the last record into new
rows. In this example I will need to add 4 rows between 26-Jan-68 and
2-Feb-68, append dates that correspond to MoTuWeTh following 26-
Jan-68, and copy the data for 26-Jan-68 into these new rows. I need to
do this for all rows (which ends on current week--lots of rows to do
manually). Any help will be appreciated.


here is a vba as your starting point:

Sub copydate()
* * Dim dt As Range, c As Range
* * Dim dtArray() As Variant
* * Dim i As Integer, j As Integer

* * Set dt = Range([a1], [a1].End(xlDown))
* * ReDim dtArray(1 To dt.Rows.Count * 5, 1 To 5)

* * i = 1
* * For Each c In dt
* * * * For j = 0 To 4
* * * * * * dtArray(i + j, 1) = c.Value + j
* * * * * * dtArray(i + j, 2) = c.Offset(0, 1)
* * * * * * dtArray(i + j, 3) = c.Offset(0, 2)
* * * * * * dtArray(i + j, 4) = c.Offset(0, 3)
* * * * * * dtArray(i + j, 5) = c.Offset(0, 4)
* * * * Next
* * * * i = i + 5
* * Next

* * Dim target As Range
* * Set target = [h1] * ' change this to where you want the new data
to be copied
* * target.Resize(dt.Rows.Count * 5, 5) = dtArray
End Sub


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Converting weekly price data into daily (5 days of the week) format

On Feb 9, 8:53*am, Don Guillett wrote:
Or

Sub insertrowsifFRIDAY()
For i = Cells(Rows.Count, 1). _
End(xlUp).Row To 1 Step -1
If Format(Cells(i, 1), "ddd") = "Fri" Then
Rows(i).Copy
Rows(i + 1).Resize(4).Insert
Cells(i + 1, 1) = Cells(i, 1) + 3
Cells(i + 1, 1).AutoFill _
*Destination:=Cells(i + 1, 1).Resize(4)
'MsgBox i
End If
Next i
End Sub

On Feb 7, 9:23*pm, reza wrote:

On Feb 7, 9:19*pm,SajjadQureshi wrote:


I have a data file that looks like this.
26-Jan-68 * * * 1.02088 1.02088 1.02088 1.02088
2-Feb-68 * * * *1.01608 1.01608 1.01608 1.01608
9-Feb-68 * * * *1.01577 1.01577 1.01577 1.01577
16-Feb-68 * * * 1.01425 1.01425 1.01425 1.01425
.........


The current date fall on FRI. I want to add new rows with dates for
the following MoTuWeTh and copy the data from the last record into new
rows. In this example I will need to add 4 rows between 26-Jan-68 and
2-Feb-68, append dates that correspond to MoTuWeTh following 26-
Jan-68, and copy the data for 26-Jan-68 into these new rows. I need to
do this for all rows (which ends on current week--lots of rows to do
manually). Any help will be appreciated.


here is a vba as your starting point:


Sub copydate()
* * Dim dt As Range, c As Range
* * Dim dtArray() As Variant
* * Dim i As Integer, j As Integer


* * Set dt = Range([a1], [a1].End(xlDown))
* * ReDim dtArray(1 To dt.Rows.Count * 5, 1 To 5)


* * i = 1
* * For Each c In dt
* * * * For j = 0 To 4
* * * * * * dtArray(i + j, 1) = c.Value + j
* * * * * * dtArray(i + j, 2) = c.Offset(0, 1)
* * * * * * dtArray(i + j, 3) = c.Offset(0, 2)
* * * * * * dtArray(i + j, 4) = c.Offset(0, 3)
* * * * * * dtArray(i + j, 5) = c.Offset(0, 4)
* * * * Next
* * * * i = i + 5
* * Next


* * Dim target As Range
* * Set target = [h1] * ' change this to where you want the new data
to be copied
* * target.Resize(dt.Rows.Count * 5, 5) = dtArray
End Sub


Thanks for your help.
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Converting weekly price data into daily (5 days of the week) format

On Feb 7, 10:23*pm, reza wrote:
On Feb 7, 9:19*pm,SajjadQureshi wrote:

I have a data file that looks like this.
26-Jan-68 * * * 1.02088 1.02088 1.02088 1.02088
2-Feb-68 * * * *1.01608 1.01608 1.01608 1.01608
9-Feb-68 * * * *1.01577 1.01577 1.01577 1.01577
16-Feb-68 * * * 1.01425 1.01425 1.01425 1.01425
.........


The current date fall on FRI. I want to add new rows with dates for
the following MoTuWeTh and copy the data from the last record into new
rows. In this example I will need to add 4 rows between 26-Jan-68 and
2-Feb-68, append dates that correspond to MoTuWeTh following 26-
Jan-68, and copy the data for 26-Jan-68 into these new rows. I need to
do this for all rows (which ends on current week--lots of rows to do
manually). Any help will be appreciated.


here is a vba as your starting point:

Sub copydate()
* * Dim dt As Range, c As Range
* * Dim dtArray() As Variant
* * Dim i As Integer, j As Integer

* * Set dt = Range([a1], [a1].End(xlDown))
* * ReDim dtArray(1 To dt.Rows.Count * 5, 1 To 5)

* * i = 1
* * For Each c In dt
* * * * For j = 0 To 4
* * * * * * dtArray(i + j, 1) = c.Value + j
* * * * * * dtArray(i + j, 2) = c.Offset(0, 1)
* * * * * * dtArray(i + j, 3) = c.Offset(0, 2)
* * * * * * dtArray(i + j, 4) = c.Offset(0, 3)
* * * * * * dtArray(i + j, 5) = c.Offset(0, 4)
* * * * Next
* * * * i = i + 5
* * Next

* * Dim target As Range
* * Set target = [h1] * ' change this to where you want the new data
to be copied
* * target.Resize(dt.Rows.Count * 5, 5) = dtArray
End Sub


It worked. Thanks in a million.


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
Converting daily data into weekly, monthly and yearly data CEGavinMcGrath Excel Discussion (Misc queries) 4 April 3rd 23 06:54 PM
How to make weekly totals change as the days in the week change ye Seth.Schwarzkopf[_2_] Excel Programming 1 March 19th 10 06:19 PM
Converting daily data into weekly Robin Excel Discussion (Misc queries) 1 October 7th 08 04:29 AM
Converting Daily Info to Weekly CEGavinMcGrath Excel Discussion (Misc queries) 5 September 9th 08 02:16 AM
Collecting weekly and monthly totals from daily data Kasper Excel Worksheet Functions 0 January 12th 06 08:02 PM


All times are GMT +1. The time now is 06:44 PM.

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

About Us

"It's about Microsoft Excel"