Simple code entering data

H

HammerJoe

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
 
B

Bob Phillips

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)
 
H

HammerJoe

Thanks for the quick reply.

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

Thanks
 
H

HammerJoe

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top