ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Simple code entering data (https://www.excelbanter.com/excel-programming/386040-simple-code-entering-data.html)

[email protected][_2_]

Simple code entering data
 
Hi,

I hope I can get some help on this one.

I am looking to do something really simple.

I need to track contacts on a daily basis.

What I want to have is a list starting at Row 4 column AA.
Each row will consist of one colum with the date (ie 2007/03/25) and
the second column the number of contacts for that day.

I want to have a button that basically increases the contacts by one
every time it is clicked.

I can create the worksheet and do all I want to do but its the coding
that messes me up. :)
When the button is clicked it needs to do the following:

Find the first empty row starting at R4ColAA.
Find the last row with a date entry starting at R4ColAA.
If it is todays date then increase ColAB by 1.

If it is not todays date then go to next row, add todays date on Col
AA and inc col AB by one.


Thats it, I know it is a pretty simple code, and any help would be
appreciated.

Thanks


Bob Phillips

Simple code entering data
 
Public Sub CommandButton1_click()
Dim iLastRow As Long
iLastRow = Cells(Rows.Count, "AA").End(xlUp).Row
If Cells(iLastRow, "AA").Value < Date Then
iLastRow = iLastRow + 1
End If
Cells(iLastRow, "AA").Value = Date
Cells(iLastRow, "AB").Value = Cells(iLastRow, "AB").Value + 1

End Sub


--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



wrote in message
oups.com...
Hi,

I hope I can get some help on this one.

I am looking to do something really simple.

I need to track contacts on a daily basis.

What I want to have is a list starting at Row 4 column AA.
Each row will consist of one colum with the date (ie 2007/03/25) and
the second column the number of contacts for that day.

I want to have a button that basically increases the contacts by one
every time it is clicked.

I can create the worksheet and do all I want to do but its the coding
that messes me up. :)
When the button is clicked it needs to do the following:

Find the first empty row starting at R4ColAA.
Find the last row with a date entry starting at R4ColAA.
If it is todays date then increase ColAB by 1.

If it is not todays date then go to next row, add todays date on Col
AA and inc col AB by one.


Thats it, I know it is a pretty simple code, and any help would be
appreciated.

Thanks




[email protected][_2_]

Simple code entering data
 
Thanks for the quick reply.

Its good, but how do I check if iLastRow has todays date?

Thanks


[email protected][_2_]

Simple code entering data
 
On Mar 25, 4:10 pm, wrote:
Thanks for the quick reply.

Its good, but how do I check if iLastRow has todays date?

Thanks


Duhhh!!!

Just Date to compare...

Thanks for all the help, problem has been solved...

Cheers.



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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com