View Single Post
 
Old 01-19-2011, 04:06 AM
tareq tareq is offline Windows 7 Office 2007
Novice
 
Join Date: Sep 2010
Posts: 15
tareq is on a distinguished road
Default How to use "if" to copy and paste data

Hi all, this is my second post in this wonderful forum, I am dealing now with another weather data. The format I need is an hourly data for each month, but what I have is a 3-6 hours data, for example i have for the date 1/1/2005 the following hours:
00.00
06.00
09.00
.
.
.

I need the data to be like this:
00.00
01.00
02.00
.
.
.
09.00

So what should be done is copy the data for the (00.00 hour) and paste them twice so I will have (00.00, 01.00 and 02.00) and they all have the same values (the value of the 00.00 hour). After that I have a missing data for hours 03.00, 04.00 and 05.00) so I have to create a row for each hour and fill each cell in those row with (9999). So I need an if statement that can see if the difference between (00.00) and (06.00) is 6 hours it will create (01.00, 02.00) from the (00.00 hour) then it will add rows for (03.00, 04.00 and 05.00) and give each cell in each row a value of (9999), and when the difference is 3 hours it will just copy and past the data of the previous hour, and in my example the difference between (06.00 and 09.00) it will only copy the data of the (06.00 hour) and paste them after it twice so it will create (07.00 and 08.00).
Now another thing, I recorded macros to arrange the original data in the form I want, but since we have months with 30 days and others with 31 and others with 29 or 28 I couldn't add that for the macro, so is there is any way I can edit the macros to make them stop after they face an empty cell??
(Attached is an example for the data I want and a list for the macros I made so someone will help me edit them)
The excel file I attached to this post contains three sheets: "original" which contains the original data, "my macros" which contain the data after I edited them using a recorded macro, and "final" which contain the data in their final format to use in the model and I highlighted the created rows in yellow, and I only put 10 in that sheet just to be brief, but when I will apply the macro I should make the whole days. And the "if" macro I will use it to the "my macros" sheet. Also you will find a list for the macros I recorded to produce the "my macros" sheet from the "original" sheet.
Please guys, I have to finish this by the end of January in order to run the wind erosion model, and I am stuck in this issue only.
Thank you all in advance
Tareq
Attached Files
File Type: xls weatherdata.xls (162.0 KB, 14 views)
File Type: txt macros.txt (32.7 KB, 12 views)
Reply With Quote