Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 36
Default Verify date by week.

Okay I import a txt file that has data by week, but if the week has no
entries it's not there so I need to add that week to the file so I can copy
it over into another
worksheet. I can't seem to get the right combination of syntax/formula
correct.

There should always be data in 12/29/07 row.

This is what I started out with.
For a = 53 to 2 step -1
Range("A"+Cstr(a)+"").activate
DateCurr = activecell.value
DatePrev = activecell.offset(-1,0).value
If DateCurr < DatePrev + 7 then
selection.entirerow.insert
Range("A"+Cstr(a)+"").value = DateCurr + 7
Next a

Do I have to do something with date() function to make this work or do I
force column a format to date?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default Verify date by week.

Try this:

I'd do it with a copy of your workbook to ensure it gives you what you want.

Sub Macro1()
Dim myRange As Range

For a = 3 To 54
Set myRange = Range("A" & a)
If myRange.Value < myRange.Offset(-1, 0).Value + 7 Then
Debug.Print myRange.Address, myRange.Value, myRange.Offset(-1, 0).Value
Debug.Print
myRange.EntireRow.Insert
Debug.Print myRange.Address
myRange.Offset(-1, 0).Value = myRange.Offset(-2, 0) + 7

End If
Next a

End Sub


"Rominall" wrote:

Okay I import a txt file that has data by week, but if the week has no
entries it's not there so I need to add that week to the file so I can copy
it over into another
worksheet. I can't seem to get the right combination of syntax/formula
correct.

There should always be data in 12/29/07 row.

This is what I started out with.
For a = 53 to 2 step -1
Range("A"+Cstr(a)+"").activate
DateCurr = activecell.value
DatePrev = activecell.offset(-1,0).value
If DateCurr < DatePrev + 7 then
selection.entirerow.insert
Range("A"+Cstr(a)+"").value = DateCurr + 7
Next a

Do I have to do something with date() function to make this work or do I
force column a format to date?

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
Convert regular Date to Week Ending or Week Beginning Dates Sam H Excel Discussion (Misc queries) 5 April 3rd 23 04:39 PM
Check if Date within this week/last week Duncan[_5_] Excel Programming 4 December 15th 06 02:37 PM
Verify user input box is a Month End Date mikeburg[_93_] Excel Programming 4 August 4th 06 05:42 PM
Forms - Verify date format Michael Beckinsale Excel Programming 5 January 23rd 06 05:30 PM
I need week number in excell from a date, first week must be mini. jPeich Excel Discussion (Misc queries) 4 January 5th 05 01:21 AM


All times are GMT +1. The time now is 07:21 PM.

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

About Us

"It's about Microsoft Excel"