![]() |
Test for record dates?
I am looking for code that would check for todays date in column A and if not
found put todays date in the last blank row on the sheet and then put values of "Count1", "Count2" and "Count3" going across in the same row, columns B,C and D. If it finds todays date do nothing. |
Test for record dates?
Sub lookit()
n = Cells(Rows.Count, "A").End(xlUp).Row + 1 For i = 1 To n If Cells(i, "A").Value = Date Then Exit Sub Next For i = Rows.Count To 1 Step -1 If Application.CountA(Rows(i)) = 0 Then With Cells(i, "A") .Value = Date .Offset(0, 1).Value = "Count1" .Offset(0, 2).Value = "Count2" .Offset(0, 3).Value = "Count3" Exit Sub End With End If Next End Sub If today's date is not found, the last empty row is found and the values entered. -- Gary''s Student - gsnu200757 "Aaron" wrote: I am looking for code that would check for todays date in column A and if not found put todays date in the last blank row on the sheet and then put values of "Count1", "Count2" and "Count3" going across in the same row, columns B,C and D. If it finds todays date do nothing. |
Test for record dates?
For some reason it is going to row 65,000+ on the second part of the code.
It is not putting the date or the count in the cells? "Gary''s Student" wrote: Sub lookit() n = Cells(Rows.Count, "A").End(xlUp).Row + 1 For i = 1 To n If Cells(i, "A").Value = Date Then Exit Sub Next For i = Rows.Count To 1 Step -1 If Application.CountA(Rows(i)) = 0 Then With Cells(i, "A") .Value = Date .Offset(0, 1).Value = "Count1" .Offset(0, 2).Value = "Count2" .Offset(0, 3).Value = "Count3" Exit Sub End With End If Next End Sub If today's date is not found, the last empty row is found and the values entered. -- Gary''s Student - gsnu200757 "Aaron" wrote: I am looking for code that would check for todays date in column A and if not found put todays date in the last blank row on the sheet and then put values of "Count1", "Count2" and "Count3" going across in the same row, columns B,C and D. If it finds todays date do nothing. |
Test for record dates?
You asked for the material to be put in the LAST blank row, not the FIRST
blank row. The last blank row is usually row 65536 -- Gary''s Student - gsnu200757 "Aaron" wrote: For some reason it is going to row 65,000+ on the second part of the code. It is not putting the date or the count in the cells? "Gary''s Student" wrote: Sub lookit() n = Cells(Rows.Count, "A").End(xlUp).Row + 1 For i = 1 To n If Cells(i, "A").Value = Date Then Exit Sub Next For i = Rows.Count To 1 Step -1 If Application.CountA(Rows(i)) = 0 Then With Cells(i, "A") .Value = Date .Offset(0, 1).Value = "Count1" .Offset(0, 2).Value = "Count2" .Offset(0, 3).Value = "Count3" Exit Sub End With End If Next End Sub If today's date is not found, the last empty row is found and the values entered. -- Gary''s Student - gsnu200757 "Aaron" wrote: I am looking for code that would check for todays date in column A and if not found put todays date in the last blank row on the sheet and then put values of "Count1", "Count2" and "Count3" going across in the same row, columns B,C and D. If it finds todays date do nothing. |
Test for record dates?
Sorry, I need it for the last blank row.
Thanks in advance. "Gary''s Student" wrote: You asked for the material to be put in the LAST blank row, not the FIRST blank row. The last blank row is usually row 65536 -- Gary''s Student - gsnu200757 "Aaron" wrote: For some reason it is going to row 65,000+ on the second part of the code. It is not putting the date or the count in the cells? "Gary''s Student" wrote: Sub lookit() n = Cells(Rows.Count, "A").End(xlUp).Row + 1 For i = 1 To n If Cells(i, "A").Value = Date Then Exit Sub Next For i = Rows.Count To 1 Step -1 If Application.CountA(Rows(i)) = 0 Then With Cells(i, "A") .Value = Date .Offset(0, 1).Value = "Count1" .Offset(0, 2).Value = "Count2" .Offset(0, 3).Value = "Count3" Exit Sub End With End If Next End Sub If today's date is not found, the last empty row is found and the values entered. -- Gary''s Student - gsnu200757 "Aaron" wrote: I am looking for code that would check for todays date in column A and if not found put todays date in the last blank row on the sheet and then put values of "Count1", "Count2" and "Count3" going across in the same row, columns B,C and D. If it finds todays date do nothing. |
Test for record dates?
This is a one line change from the original solution:
Sub lookit() n = Cells(Rows.Count, "A").End(xlUp).Row + 1 For i = 1 To n If Cells(i, "A").Value = Date Then Exit Sub Next For i = 1 To Rows.Count If Application.CountA(Rows(i)) = 0 Then With Cells(i, "A") .Value = Date .Offset(0, 1).Value = "Count1" .Offset(0, 2).Value = "Count2" .Offset(0, 3).Value = "Count3" Exit Sub End With End If Next End Sub The original started from 65536 and worked backwards looking for a blank line. This solution starts from row #1 and works forward. The pasting will occur near your working area rather than at the very bottom of a worksheet. -- Gary''s Student - gsnu200757 "Aaron" wrote: Sorry, I need it for the last blank row. Thanks in advance. "Gary''s Student" wrote: You asked for the material to be put in the LAST blank row, not the FIRST blank row. The last blank row is usually row 65536 -- Gary''s Student - gsnu200757 "Aaron" wrote: For some reason it is going to row 65,000+ on the second part of the code. It is not putting the date or the count in the cells? "Gary''s Student" wrote: Sub lookit() n = Cells(Rows.Count, "A").End(xlUp).Row + 1 For i = 1 To n If Cells(i, "A").Value = Date Then Exit Sub Next For i = Rows.Count To 1 Step -1 If Application.CountA(Rows(i)) = 0 Then With Cells(i, "A") .Value = Date .Offset(0, 1).Value = "Count1" .Offset(0, 2).Value = "Count2" .Offset(0, 3).Value = "Count3" Exit Sub End With End If Next End Sub If today's date is not found, the last empty row is found and the values entered. -- Gary''s Student - gsnu200757 "Aaron" wrote: I am looking for code that would check for todays date in column A and if not found put todays date in the last blank row on the sheet and then put values of "Count1", "Count2" and "Count3" going across in the same row, columns B,C and D. If it finds todays date do nothing. |
All times are GMT +1. The time now is 01:18 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com