Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Add days to date

I want the code to pick dates from column Q (see line 4) add 7 days and put
the new dates into column k.

Any suggestions?

Sub copy_Dates()
Sheets(2).Range("e4:e65536").Value = Sheets(1).Range("d4:d65536")
Sheets(1).Range("n4:Q65536").Value = Sheets(2).Range("f4:i65536").Value
Sheets(1).Range("k4:K65536").Value = Range("q4:q65536").Value
Sheets(1).Select
Range("k65536").End(xlUp).Activate
If ActiveCell.Value <= Now - 30 Then
msgbox "NICE!!"
Else: Exit Sub
End If
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Add days to date

Hi,

Use the DateAdd method. This adds 7 days to a date in Col Q and puts it in
Col K

Sub Copy_Dates()
Set sht = Sheets(1)
Dim LastRow As Long
Dim c As Range
LastRow = sht.Cells(Cells.Rows.Count, "Q").End(xlUp).Row
Set MyRange = sht.Range("Q4:Q" & LastRow)
For Each c In MyRange
If IsDate(c) Then
c.Offset(, -6).Value = DateAdd("d", 7, c.Value)
End If
Next
End Sub

--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"tomjoe" wrote:

I want the code to pick dates from column Q (see line 4) add 7 days and put
the new dates into column k.

Any suggestions?

Sub copy_Dates()
Sheets(2).Range("e4:e65536").Value = Sheets(1).Range("d4:d65536")
Sheets(1).Range("n4:Q65536").Value = Sheets(2).Range("f4:i65536").Value
Sheets(1).Range("k4:K65536").Value = Range("q4:q65536").Value
Sheets(1).Select
Range("k65536").End(xlUp).Activate
If ActiveCell.Value <= Now - 30 Then
msgbox "NICE!!"
Else: Exit Sub
End If
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Add days to date

Hi Mike
Worked like a charm.
Awsome simple and terrible smart.
Thank you so much.


Mike H skrev:

Hi,

Use the DateAdd method. This adds 7 days to a date in Col Q and puts it in
Col K

Sub Copy_Dates()
Set sht = Sheets(1)
Dim LastRow As Long
Dim c As Range
LastRow = sht.Cells(Cells.Rows.Count, "Q").End(xlUp).Row
Set MyRange = sht.Range("Q4:Q" & LastRow)
For Each c In MyRange
If IsDate(c) Then
c.Offset(, -6).Value = DateAdd("d", 7, c.Value)
End If
Next
End Sub

--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"tomjoe" wrote:

I want the code to pick dates from column Q (see line 4) add 7 days and put
the new dates into column k.

Any suggestions?

Sub copy_Dates()
Sheets(2).Range("e4:e65536").Value = Sheets(1).Range("d4:d65536")
Sheets(1).Range("n4:Q65536").Value = Sheets(2).Range("f4:i65536").Value
Sheets(1).Range("k4:K65536").Value = Range("q4:q65536").Value
Sheets(1).Select
Range("k65536").End(xlUp).Activate
If ActiveCell.Value <= Now - 30 Then
msgbox "NICE!!"
Else: Exit Sub
End If
End Sub

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Add days to date

Glad i could help and thanks for the feedback
--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"tomjoe" wrote:

Hi Mike
Worked like a charm.
Awsome simple and terrible smart.
Thank you so much.


Mike H skrev:

Hi,

Use the DateAdd method. This adds 7 days to a date in Col Q and puts it in
Col K

Sub Copy_Dates()
Set sht = Sheets(1)
Dim LastRow As Long
Dim c As Range
LastRow = sht.Cells(Cells.Rows.Count, "Q").End(xlUp).Row
Set MyRange = sht.Range("Q4:Q" & LastRow)
For Each c In MyRange
If IsDate(c) Then
c.Offset(, -6).Value = DateAdd("d", 7, c.Value)
End If
Next
End Sub

--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"tomjoe" wrote:

I want the code to pick dates from column Q (see line 4) add 7 days and put
the new dates into column k.

Any suggestions?

Sub copy_Dates()
Sheets(2).Range("e4:e65536").Value = Sheets(1).Range("d4:d65536")
Sheets(1).Range("n4:Q65536").Value = Sheets(2).Range("f4:i65536").Value
Sheets(1).Range("k4:K65536").Value = Range("q4:q65536").Value
Sheets(1).Select
Range("k65536").End(xlUp).Activate
If ActiveCell.Value <= Now - 30 Then
msgbox "NICE!!"
Else: Exit Sub
End If
End Sub

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Add days to date

Or just add 7 (since you're adding days):

If IsDate(c) Then
with c.Offset(, -6)
.Value = .value + 7
end with
End If

Mike H wrote:

Hi,

Use the DateAdd method. This adds 7 days to a date in Col Q and puts it in
Col K

Sub Copy_Dates()
Set sht = Sheets(1)
Dim LastRow As Long
Dim c As Range
LastRow = sht.Cells(Cells.Rows.Count, "Q").End(xlUp).Row
Set MyRange = sht.Range("Q4:Q" & LastRow)
For Each c In MyRange
If IsDate(c) Then
c.Offset(, -6).Value = DateAdd("d", 7, c.Value)
End If
Next
End Sub

--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.

"tomjoe" wrote:

I want the code to pick dates from column Q (see line 4) add 7 days and put
the new dates into column k.

Any suggestions?

Sub copy_Dates()
Sheets(2).Range("e4:e65536").Value = Sheets(1).Range("d4:d65536")
Sheets(1).Range("n4:Q65536").Value = Sheets(2).Range("f4:i65536").Value
Sheets(1).Range("k4:K65536").Value = Range("q4:q65536").Value
Sheets(1).Select
Range("k65536").End(xlUp).Activate
If ActiveCell.Value <= Now - 30 Then
msgbox "NICE!!"
Else: Exit Sub
End If
End Sub


--

Dave Peterson
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
Need to pull <=14 Days, <=30 Days, 30 Days from a date column Ken Excel Discussion (Misc queries) 3 October 23rd 09 12:53 AM
Conditional Formatting Dates calculating 10 days and 30 days from a certain date Sioux[_2_] Excel Worksheet Functions 2 October 11th 07 02:04 PM
Report Date - Date Recv = Days Late, but how to rid completed date MS Questionnairess Excel Worksheet Functions 1 January 24th 07 11:05 PM
TWO DATES,150 DAYS APART,NEED ONE DATE TO TURN RED AFTER 150 DAYS 440 Excel Programming 3 September 22nd 06 05:24 PM
Calculating days between current date and a date in future NETWORKDAYS() function Faheem Khan Excel Worksheet Functions 2 February 10th 05 07:18 PM


All times are GMT +1. The time now is 02:37 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"