Automating copying data

AventAClue

New Member
Joined
Sep 4, 2011
Messages
21
Hi all,


Looking for some help if anyone can do so please?


I have two worksheets, and wish to copy data from one to the other, matching it up to the date column on the second worksheet.


Worksheet “DataDownload” simply holds data in both columns A and B.
Column A cells hold a date / time stamp in the format below, and a corresponding value for that time is in the adjacent cell in Column B ( each cell in column A increments 5 minutes from the one previously).
Column A Column B
<table class="MsoNormalTable" style="width: 155.15pt; border-collapse: collapse;" border="0" cellpadding="0" cellspacing="0" width="207"> <tbody><tr style="height: 13.55pt;"> <td style="width: 118.85pt; padding: 0cm 5.4pt; height: 13.55pt;" valign="bottom" width="158" nowrap="nowrap">
</td> <td style="width: 36.3pt; padding: 0cm 5.4pt; height: 13.55pt;" valign="bottom" width="48" nowrap="nowrap">
</td> </tr> <tr style="height: 13.55pt;"> <td style="width: 118.85pt; padding: 0cm 5.4pt; height: 13.55pt;" valign="bottom" width="158" nowrap="nowrap">
Date stamp​
</td> <td style="width: 36.3pt; padding: 0cm 5.4pt; height: 13.55pt;" valign="bottom" width="48" nowrap="nowrap">
Value​
</td> </tr> <tr style="height: 13.55pt;"> <td style="width: 118.85pt; padding: 0cm 5.4pt; height: 13.55pt;" valign="bottom" width="158" nowrap="nowrap">
.​
.​
.​
</td> <td style="width: 36.3pt; padding: 0cm 5.4pt; height: 13.55pt;" valign="bottom" width="48" nowrap="nowrap">
</td> </tr> <tr style="height: 13.55pt;"> <td style="width: 118.85pt; padding: 0cm 5.4pt; height: 13.55pt;" valign="bottom" width="158" nowrap="nowrap">
28/07/2011 23:45
</td> <td style="width: 36.3pt; padding: 0cm 5.4pt; height: 13.55pt;" valign="bottom" width="48" nowrap="nowrap">
1230
</td> </tr> <tr style="height: 13.55pt;"> <td style="width: 118.85pt; padding: 0cm 5.4pt; height: 13.55pt;" valign="bottom" width="158" nowrap="nowrap">
28/07/2011 23:50
</td> <td style="width: 36.3pt; padding: 0cm 5.4pt; height: 13.55pt;" valign="bottom" width="48" nowrap="nowrap">
1228
</td> </tr> <tr style="height: 13.55pt;"> <td style="width: 118.85pt; padding: 0cm 5.4pt; height: 13.55pt;" valign="bottom" width="158" nowrap="nowrap">
28/07/2011 23:55
</td> <td style="width: 36.3pt; padding: 0cm 5.4pt; height: 13.55pt;" valign="bottom" width="48" nowrap="nowrap">
1259
</td> </tr> <tr style="height: 13.55pt;"> <td style="width: 118.85pt; padding: 0cm 5.4pt; height: 13.55pt;" valign="bottom" width="158" nowrap="nowrap">
29/07/2011 0:00
</td> <td style="width: 36.3pt; padding: 0cm 5.4pt; height: 13.55pt;" valign="bottom" width="48" nowrap="nowrap">
1260
</td> </tr> <tr style="height: 13.55pt;"> <td style="width: 118.85pt; padding: 0cm 5.4pt; height: 13.55pt;" valign="bottom" width="158" nowrap="nowrap">
29/07/2011 0:05
</td> <td style="width: 36.3pt; padding: 0cm 5.4pt; height: 13.55pt;" valign="bottom" width="48" nowrap="nowrap">
1224
</td> </tr> <tr style="height: 13.55pt;"> <td style="width: 118.85pt; padding: 0cm 5.4pt; height: 13.55pt;" valign="bottom" width="158" nowrap="nowrap">
29/07/2011 0:10
</td> <td style="width: 36.3pt; padding: 0cm 5.4pt; height: 13.55pt;" valign="bottom" width="48" nowrap="nowrap">
1223
</td> </tr> <tr style="height: 13.55pt;"> <td style="width: 118.85pt; padding: 0cm 5.4pt; height: 13.55pt;" valign="bottom" width="158" nowrap="nowrap">
29/07/2011 0:15
</td> <td style="width: 36.3pt; padding: 0cm 5.4pt; height: 13.55pt;" valign="bottom" width="48" nowrap="nowrap">
1223
</td> </tr> <tr style="height: 13.55pt;"> <td style="width: 118.85pt; padding: 0cm 5.4pt; height: 13.55pt;" valign="bottom" width="158" nowrap="nowrap">
29/07/2011 0:20
</td> <td style="width: 36.3pt; padding: 0cm 5.4pt; height: 13.55pt;" valign="bottom" width="48" nowrap="nowrap">
1225
</td> </tr> <tr style="height: 13.55pt;"> <td style="width: 118.85pt; padding: 0cm 5.4pt; height: 13.55pt;" valign="bottom" width="158" nowrap="nowrap">
29/07/2011 0:25
</td> <td style="width: 36.3pt; padding: 0cm 5.4pt; height: 13.55pt;" valign="bottom" width="48" nowrap="nowrap">
345
</td> </tr> <tr style="height: 13.55pt;"> <td style="width: 118.85pt; padding: 0cm 5.4pt; height: 13.55pt;" valign="bottom" width="158" nowrap="nowrap">
29/07/2011 0:30
</td> <td style="width: 36.3pt; padding: 0cm 5.4pt; height: 13.55pt;" valign="bottom" width="48" nowrap="nowrap">
26
</td> </tr> <tr style="height: 13.55pt;"> <td style="width: 118.85pt; padding: 0cm 5.4pt; height: 13.55pt;" valign="bottom" width="158" nowrap="nowrap">
29/07/2011 0:35
</td> <td style="width: 36.3pt; padding: 0cm 5.4pt; height: 13.55pt;" valign="bottom" width="48" nowrap="nowrap">
25
</td> </tr> <tr style="height: 13.55pt;"> <td style="width: 118.85pt; padding: 0cm 5.4pt; height: 13.55pt;" valign="bottom" width="158" nowrap="nowrap">
29/07/2011 0:40
</td> <td style="width: 36.3pt; padding: 0cm 5.4pt; height: 13.55pt;" valign="bottom" width="48" nowrap="nowrap">
43
</td> </tr> <tr style="height: 13.55pt;"> <td style="width: 118.85pt; padding: 0cm 5.4pt; height: 13.55pt;" valign="bottom" width="158" nowrap="nowrap">
29/07/2011 0:45
</td> <td style="width: 36.3pt; padding: 0cm 5.4pt; height: 13.55pt;" valign="bottom" width="48" nowrap="nowrap">
63
</td> </tr> <tr style="height: 13.55pt;"> <td style="width: 118.85pt; padding: 0cm 5.4pt; height: 13.55pt;" valign="bottom" width="158" nowrap="nowrap">
29/07/2011 0:50
</td> <td style="width: 36.3pt; padding: 0cm 5.4pt; height: 13.55pt;" valign="bottom" width="48" nowrap="nowrap">
46
</td> </tr> <tr style="height: 13.55pt;"> <td style="width: 118.85pt; padding: 0cm 5.4pt; height: 13.55pt;" valign="bottom" width="158" nowrap="nowrap">
.
</td> <td style="width: 36.3pt; padding: 0cm 5.4pt; height: 13.55pt;" valign="bottom" width="48" nowrap="nowrap">
</td> </tr> <tr style="height: 13.55pt;"> <td style="width: 118.85pt; padding: 0cm 5.4pt; height: 13.55pt;" valign="bottom" width="158" nowrap="nowrap">
.
</td> <td style="width: 36.3pt; padding: 0cm 5.4pt; height: 13.55pt;" valign="bottom" width="48" nowrap="nowrap">
</td> </tr> <tr style="height: 13.55pt;"> <td style="width: 118.85pt; padding: 0cm 5.4pt; height: 13.55pt;" valign="bottom" width="158" nowrap="nowrap">
.
</td> <td style="width: 36.3pt; padding: 0cm 5.4pt; height: 13.55pt;" valign="bottom" width="48" nowrap="nowrap">
</td> </tr> </tbody></table>


Worksheet “Manipulated” shows only the date along Row 2, and the corresponding values for that date (ie all values associated with that date) are entered in row 4 down to row 291, and then the next date down the next column, and the next date, and so on till there is no more data available.
<table class="MsoNormalTable" style="width: 277.15pt; margin-left: 4.65pt; border-collapse: collapse;" border="0" cellpadding="0" cellspacing="0" width="370"> <tbody><tr style="height: 15pt;"> <td style="width: 57.45pt; padding: 0cm 5.4pt; height: 15pt;" valign="bottom" width="77" nowrap="nowrap">
Tue
</td> <td style="width: 49.65pt; padding: 0cm 5.4pt; height: 15pt;" valign="bottom" width="66" nowrap="nowrap">
Wed
</td> <td style="width: 53.35pt; padding: 0cm 5.4pt; height: 15pt;" valign="bottom" width="71" nowrap="nowrap">
Thu
</td> <td style="width: 58.35pt; padding: 0cm 5.4pt; height: 15pt;" valign="bottom" width="78" nowrap="nowrap">
Fri
</td> <td style="width: 58.35pt; padding: 0cm 5.4pt; height: 15pt;" valign="bottom" width="78" nowrap="nowrap">
Sat
</td> </tr> <tr style="height: 15pt;"> <td style="width: 57.45pt; border-width: 1pt medium; border-style: solid none; border-color: windowtext -moz-use-text-color; padding: 0cm 5.4pt; height: 15pt;" valign="bottom" width="77" nowrap="nowrap">
29-Jul-11
</td> <td style="width: 49.65pt; border-width: 1pt medium; border-style: solid none; border-color: windowtext -moz-use-text-color; padding: 0cm 5.4pt; height: 15pt;" valign="bottom" width="66" nowrap="nowrap">
30-Jul-11
</td> <td style="width: 53.35pt; border-width: 1pt medium; border-style: solid none; border-color: windowtext -moz-use-text-color; padding: 0cm 5.4pt; height: 15pt;" valign="bottom" width="71" nowrap="nowrap">
31-Jul-11
</td> <td style="width: 58.35pt; border-width: 1pt medium; border-style: solid none; border-color: windowtext -moz-use-text-color; padding: 0cm 5.4pt; height: 15pt;" valign="bottom" width="78" nowrap="nowrap">
12-Aug-11
</td> <td style="width: 58.35pt; border-width: 1pt medium; border-style: solid none; border-color: windowtext -moz-use-text-color; padding: 0cm 5.4pt; height: 15pt;" valign="bottom" width="78" nowrap="nowrap">
13-Aug-11
</td> </tr> <tr style="height: 15.75pt;"> <td style="width: 57.45pt; padding: 0cm 5.4pt; height: 15.75pt;" valign="bottom" width="77" nowrap="nowrap">
Pulses
</td> <td style="width: 49.65pt; padding: 0cm 5.4pt; height: 15.75pt;" valign="bottom" width="66" nowrap="nowrap">
Pulses
</td> <td style="width: 53.35pt; padding: 0cm 5.4pt; height: 15.75pt;" valign="bottom" width="71" nowrap="nowrap">
Pulses
</td> <td style="width: 58.35pt; padding: 0cm 5.4pt; height: 15.75pt;" valign="bottom" width="78" nowrap="nowrap">
Pulses
</td> <td style="width: 58.35pt; padding: 0cm 5.4pt; height: 15.75pt;" valign="bottom" width="78" nowrap="nowrap">
Pulses
</td> </tr> <tr style="height: 15pt;"> <td style="width: 57.45pt; background: none repeat scroll 0% 0% rgb(238, 236, 225); padding: 0cm 5.4pt; height: 15pt;" valign="bottom" width="77" nowrap="nowrap">
345
</td> <td style="width: 49.65pt; background: none repeat scroll 0% 0% rgb(238, 236, 225); padding: 0cm 5.4pt; height: 15pt;" valign="bottom" width="66" nowrap="nowrap">
32
</td> <td style="width: 53.35pt; background: none repeat scroll 0% 0% rgb(238, 236, 225); padding: 0cm 5.4pt; height: 15pt;" valign="bottom" width="71" nowrap="nowrap">
32
</td> <td style="width: 58.35pt; background: none repeat scroll 0% 0% rgb(238, 236, 225); padding: 0cm 5.4pt; height: 15pt;" valign="bottom" width="78" nowrap="nowrap">
53
</td> <td style="width: 58.35pt; background: none repeat scroll 0% 0% rgb(238, 236, 225); padding: 0cm 5.4pt; height: 15pt;" valign="bottom" width="78" nowrap="nowrap">
774
</td> </tr> <tr style="height: 15pt;"> <td style="width: 57.45pt; background: none repeat scroll 0% 0% rgb(238, 236, 225); padding: 0cm 5.4pt; height: 15pt;" valign="bottom" width="77" nowrap="nowrap">
26
</td> <td style="width: 49.65pt; background: none repeat scroll 0% 0% rgb(238, 236, 225); padding: 0cm 5.4pt; height: 15pt;" valign="bottom" width="66" nowrap="nowrap">
31
</td> <td style="width: 53.35pt; background: none repeat scroll 0% 0% rgb(238, 236, 225); padding: 0cm 5.4pt; height: 15pt;" valign="bottom" width="71" nowrap="nowrap">
32
</td> <td style="width: 58.35pt; background: none repeat scroll 0% 0% rgb(238, 236, 225); padding: 0cm 5.4pt; height: 15pt;" valign="bottom" width="78" nowrap="nowrap">
31
</td> <td style="width: 58.35pt; background: none repeat scroll 0% 0% rgb(238, 236, 225); padding: 0cm 5.4pt; height: 15pt;" valign="bottom" width="78" nowrap="nowrap">
26
</td> </tr> <tr style="height: 15pt;"> <td style="width: 57.45pt; background: none repeat scroll 0% 0% rgb(238, 236, 225); padding: 0cm 5.4pt; height: 15pt;" valign="bottom" width="77" nowrap="nowrap">
25
</td> <td style="width: 49.65pt; background: none repeat scroll 0% 0% rgb(238, 236, 225); padding: 0cm 5.4pt; height: 15pt;" valign="bottom" width="66" nowrap="nowrap">
31
</td> <td style="width: 53.35pt; background: none repeat scroll 0% 0% rgb(238, 236, 225); padding: 0cm 5.4pt; height: 15pt;" valign="bottom" width="71" nowrap="nowrap">
32
</td> <td style="width: 58.35pt; background: none repeat scroll 0% 0% rgb(238, 236, 225); padding: 0cm 5.4pt; height: 15pt;" valign="bottom" width="78" nowrap="nowrap">
33
</td> <td style="width: 58.35pt; background: none repeat scroll 0% 0% rgb(238, 236, 225); padding: 0cm 5.4pt; height: 15pt;" valign="bottom" width="78" nowrap="nowrap">
26
</td> </tr> <tr style="height: 15pt;"> <td style="width: 57.45pt; background: none repeat scroll 0% 0% rgb(238, 236, 225); padding: 0cm 5.4pt; height: 15pt;" valign="bottom" width="77" nowrap="nowrap">
43
</td> <td style="width: 49.65pt; background: none repeat scroll 0% 0% rgb(238, 236, 225); padding: 0cm 5.4pt; height: 15pt;" valign="bottom" width="66" nowrap="nowrap">
32
</td> <td style="width: 53.35pt; background: none repeat scroll 0% 0% rgb(238, 236, 225); padding: 0cm 5.4pt; height: 15pt;" valign="bottom" width="71" nowrap="nowrap">
32
</td> <td style="width: 58.35pt; background: none repeat scroll 0% 0% rgb(238, 236, 225); padding: 0cm 5.4pt; height: 15pt;" valign="bottom" width="78" nowrap="nowrap">
32
</td> <td style="width: 58.35pt; background: none repeat scroll 0% 0% rgb(238, 236, 225); padding: 0cm 5.4pt; height: 15pt;" valign="bottom" width="78" nowrap="nowrap">
25
</td> </tr> <tr style="height: 15pt;"> <td style="width: 57.45pt; background: none repeat scroll 0% 0% rgb(238, 236, 225); padding: 0cm 5.4pt; height: 15pt;" valign="bottom" width="77" nowrap="nowrap">
46
</td> <td style="width: 49.65pt; background: none repeat scroll 0% 0% rgb(238, 236, 225); padding: 0cm 5.4pt; height: 15pt;" valign="bottom" width="66" nowrap="nowrap">
31
</td> <td style="width: 53.35pt; background: none repeat scroll 0% 0% rgb(238, 236, 225); padding: 0cm 5.4pt; height: 15pt;" valign="bottom" width="71" nowrap="nowrap">
32
</td> <td style="width: 58.35pt; background: none repeat scroll 0% 0% rgb(238, 236, 225); padding: 0cm 5.4pt; height: 15pt;" valign="bottom" width="78" nowrap="nowrap">
31
</td> <td style="width: 58.35pt; background: none repeat scroll 0% 0% rgb(238, 236, 225); padding: 0cm 5.4pt; height: 15pt;" valign="bottom" width="78" nowrap="nowrap">
65
</td> </tr> <tr style="height: 15pt;"> <td style="width: 57.45pt; background: none repeat scroll 0% 0% rgb(238, 236, 225); padding: 0cm 5.4pt; height: 15pt;" valign="bottom" width="77" nowrap="nowrap">
.
</td> <td style="width: 49.65pt; background: none repeat scroll 0% 0% rgb(238, 236, 225); padding: 0cm 5.4pt; height: 15pt;" valign="bottom" width="66" nowrap="nowrap">
.
</td> <td style="width: 53.35pt; background: none repeat scroll 0% 0% rgb(238, 236, 225); padding: 0cm 5.4pt; height: 15pt;" valign="bottom" width="71" nowrap="nowrap">
.
</td> <td style="width: 58.35pt; background: none repeat scroll 0% 0% rgb(238, 236, 225); padding: 0cm 5.4pt; height: 15pt;" valign="bottom" width="78" nowrap="nowrap">
.
</td> <td style="width: 58.35pt; background: none repeat scroll 0% 0% rgb(238, 236, 225); padding: 0cm 5.4pt; height: 15pt;" valign="bottom" width="78" nowrap="nowrap">
.
</td> </tr> <tr style="height: 15pt;"> <td style="width: 57.45pt; background: none repeat scroll 0% 0% rgb(238, 236, 225); padding: 0cm 5.4pt; height: 15pt;" valign="bottom" width="77" nowrap="nowrap">
.
</td> <td style="width: 49.65pt; background: none repeat scroll 0% 0% rgb(238, 236, 225); padding: 0cm 5.4pt; height: 15pt;" valign="bottom" width="66" nowrap="nowrap">
.
</td> <td style="width: 53.35pt; background: none repeat scroll 0% 0% rgb(238, 236, 225); padding: 0cm 5.4pt; height: 15pt;" valign="bottom" width="71" nowrap="nowrap">
.
</td> <td style="width: 58.35pt; background: none repeat scroll 0% 0% rgb(238, 236, 225); padding: 0cm 5.4pt; height: 15pt;" valign="bottom" width="78" nowrap="nowrap">
.
</td> <td style="width: 58.35pt; background: none repeat scroll 0% 0% rgb(238, 236, 225); padding: 0cm 5.4pt; height: 15pt;" valign="bottom" width="78" nowrap="nowrap">
.
</td> </tr> <tr style="height: 15pt;"> <td style="width: 57.45pt; background: none repeat scroll 0% 0% rgb(238, 236, 225); padding: 0cm 5.4pt; height: 15pt;" valign="bottom" width="77" nowrap="nowrap">
.
</td> <td style="width: 49.65pt; background: none repeat scroll 0% 0% rgb(238, 236, 225); padding: 0cm 5.4pt; height: 15pt;" valign="bottom" width="66" nowrap="nowrap">
.
</td> <td style="width: 53.35pt; background: none repeat scroll 0% 0% rgb(238, 236, 225); padding: 0cm 5.4pt; height: 15pt;" valign="bottom" width="71" nowrap="nowrap">
.
</td> <td style="width: 58.35pt; background: none repeat scroll 0% 0% rgb(238, 236, 225); padding: 0cm 5.4pt; height: 15pt;" valign="bottom" width="78" nowrap="nowrap">
.
</td> <td style="width: 58.35pt; background: none repeat scroll 0% 0% rgb(238, 236, 225); padding: 0cm 5.4pt; height: 15pt;" valign="bottom" width="78" nowrap="nowrap">
.
</td> </tr> </tbody></table>

I have a template for the “Manipulated” worksheet and I start by placing the first date of the records (from worksheet DataDownload) into cell B2, and then drag /autofill that along row 2 for approx 100 days.
I then go to worksheet “datadownload” and copy all the values in column B relating to that first date, starting at the 5 minute mark of that date (as that’s the first 5 mins of data), and finishing at 00:00 of the next date (which is always going to be 288 cells).
Paste those values into worksheet “manipulated” under the first date, beginning at cell B4, through to cell B291
Do the same thing for the next date, and so on, and so on……


I’m hoping to automate this process, as it’s very slow going, and open to errors on my behalf as I lose concentration.
I'd actually like if I could have a macro button that on pressing, sees the first date on the "manipulated" worksheet, copies and pastes the appropriate data from "'datadownload" worksheet, and loops through all the dates available .

Thanks for looking and hope someone can help :)

Cheers.
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Can we clarify a few things please?

1. Why does your 'Manipulated' sheet sample for 29 July start with 345? From your description, I thought it would start with 1224, being the value from the 5 minute value of that date.

2. Would there ever already be data on the 'Manipulated' sheet for a date in the 'DataDownload' sheet? If so, would the current data over-write existing data or be appended in the column below the existing data.

3. Can you confirm whether the date/time values in 'DataDownload' are actual dates or text? For example, if one of those date/times are in A10, what does this formula (placed in a vacant cell) return?
=ISNUMBER(A10)

4. On 'DataDownload' what cell is the very first date/time value? A1, A2, something else?

5. On 'Manipulated' which column contains the first date?
 
Upvote 0
Hi Peter

Thanks for your reply.
My apologies.. I’d taken a snapshot of both worksheets and tried to put it into my original post but for the life of me couldn’t find a way to put an image up there like I’ve seen on some others.
I quickly typed up something for an example to try and show what I was talking about, and in the process, I've not been accurate with my figures.

1- Yes, you are correct. If that was the first date entry then it would start with 1224 in cell B4


2- The “datadownload” sheet (in fact it is actually a separate file, a csv file) is continually accessed whenever I force a download and the data is appended to the bottom of that file.
As I’ve been manually transferring that info over onto a new “manipulated”worksheet (file) I’ve always been adding it to where I last left off. If it were an automated process it wouldn’t matter really as the data on the “datadownload” file will have the same info for the dates it already has.
I should mention the total amount of dates will normally be within a hundred as it is a billing period, and that is generally around 90 days.


3- It returns a TRUE


4- The very first one is A2


5- The first date is B2, and the value begins in B4 thru to B291


Thanks again for your help :)
 
Upvote 0
Sorry, a couple more questions ..

4. On 'DataDownload' what cell is the very first date/time value? A1, A2, something else?
4- The very first one is A2
1. Is this first date/time in A2 always a '5 minute value? That is, is it
dd/mm/yyyy 0:05? Or is it always some other specific time or could it be any time of day?

2. Does the date in this A2 value (cell A2 of 'DataDownload') equal the first date (cell B2) in sheet 'Manipulated'?
 
Upvote 0
Thanks Peter,

It could be any time really. It will always be a 5 or a zero though, and increment by 5.

The data on the csv file begins when it is first force downloaded, so if that was at 5pm, then it would start at 17:00.
Given as I then have a choice of completely overwriting the information, or just appending the new stuff, and I've been appending, whatever it starts with remains.

At some stage when the file gets large, and/or possibly at the beginning of each billing period, I will rename the existing csv file, and start a new file, and a new "manipulated" file as well. If I had to, I could align 00:05 with A2 by downloading data from the day before and then deleting rows until it starts at A2.

In answer to your second question, No.
The current csv file has spanned across two billing periods and I started transferring information from a start time that was in sync with the actual period.
BUT, I choose and place the date in cell B2 of the "manipulated" worksheet, so I was hoping that the process would compare my start date, scrolling through Column A of "Datadownload"till it hits the date equivalent to the one "manipulated" starts with (in B2), and then grab the data.

I hope that makes sense :rolleyes:
 
Upvote 0
Try this in a copy of your workbook.

<font face=Courier New><br><SPAN style="color:#00007F">Sub</SPAN> CopyData()<br>    <SPAN style="color:#00007F">Dim</SPAN> wsM <SPAN style="color:#00007F">As</SPAN> Worksheet, wsDD <SPAN style="color:#00007F">As</SPAN> Worksheet<br>    <SPAN style="color:#00007F">Dim</SPAN> StDate <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Long</SPAN>, r <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Long</SPAN>, lc <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Long</SPAN>, c <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Long</SPAN><br>   <br>    <SPAN style="color:#00007F">Set</SPAN> wsM = Sheets("Manipulated")<br>    <SPAN style="color:#00007F">Set</SPAN> wsDD = Sheets("DataDownload")<br>    <SPAN style="color:#00007F">With</SPAN> wsM<br>        StDate = .Range("B2").Value<br>        lc = .Cells(2, .Columns.Count).End(xlToLeft).Column<br>    <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN><br>    <SPAN style="color:#00007F">With</SPAN> wsDD<br>        r = 1<br>        <SPAN style="color:#00007F">Do</SPAN><br>            r = r + 1<br>        <SPAN style="color:#00007F">Loop</SPAN> <SPAN style="color:#00007F">While</SPAN> Int(.Cells(r, 1).Value) <> StDate<br>        r = r + 1<br>        Application.ScreenUpdating = <SPAN style="color:#00007F">False</SPAN><br>        <SPAN style="color:#00007F">For</SPAN> c = 2 <SPAN style="color:#00007F">To</SPAN> lc<br>            wsM.Cells(4, c).Resize(288).Value = .Cells(r, 2).Resize(288).Value<br>            r = r + 288<br>        <SPAN style="color:#00007F">Next</SPAN> c<br>        Application.ScreenUpdating = <SPAN style="color:#00007F">True</SPAN><br>    <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN><br>End <SPAN style="color:#00007F">Sub</SPAN><br></FONT>
 
Upvote 0
Hi Peter,

Thankyou

That code works perfect! It does exactly as requested and soooo quickly! :biggrin:
I spent ages copying and pasting the data beforehand.

Thankyou sooo much for your effort as well as how quickly you've responded! :)
Much appreciated!



May I be so bold as to ask for help in adding one last step to the process?

Currently that code works when the worksheets are in the same file of course (which is exactly how I explained it to you). That means firstly I need to copy the data from the csv file (seperate file) and paste it onto my workbook "DataDownload" sheet .

Is it possible to add a little code preceeding that which you've already supplied, that on pressing the macro button behaves as such:

-Asks which file i wish to open
-Upon me locating and selecting it, copies the sheet contents (can be the whole csv file sheet)
-Closes that file and pastes the copied data to "DataDownload" before running the code you previously supplied and loading the values in "Manipulated" worksheet.

I know another option may be to place it directly from the csv file into the "Manipulated" worksheet but, as these are related to each billing period, I can erase the data on the original csv file at the end of each period, close off my file, and still retain the relative information for those dates on the "DataDownload" worksheet.


Thank you once again for all your help.
 
Upvote 0
Is it possible to add a little code preceeding that which you've already supplied, that on pressing the macro button behaves as such:

-Asks which file i wish to open
-Upon me locating and selecting it, copies the sheet contents (can be the whole csv file sheet)
-Closes that file and pastes the copied data to "DataDownload" before running the code you previously supplied and loading the values in "Manipulated" worksheet.
I'm sure that would be possible, but it isn't an area I have much expertise in.

Perhaps you could start a new thread and ask about choosing thye csv file and getting the data from that file into a worksheet (called DataDownload). If you do that, I suggest you post a link to the new thread here so that we don't end up with some people trying to answer that part here and others trying to answer it in the new thread.

Subsequently we could look at combining the 2 codes if you are unable to do that yourself.
 
Upvote 0

Forum statistics

Threads
1,224,531
Messages
6,179,384
Members
452,908
Latest member
MTDelphis

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