Find Last entry

GinoZ

Board Regular
Joined
Feb 6, 2006
Messages
169
Hey guys, I have the following array

Code:
A   B    C    D   E

1   5    A    4    5
2   6    V    5    4
3   4         6    3
4   7    W         3
5   0    0    0    0 
6   0    0    0    0

The fist column represents day. I need a VBA-code to find the last day that is filled in. Day that are not filled in have zero's as entry. n this example i want to find day 4. Some spaces are blanc.
Thanks in advance

Gino
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Give this a try:
Code:
Sub MyMacro()
Dim Limit As Long
Dim c As Long
Limit = Cells(Rows.Count, 1).End(xlUp).Row
For c = Limit To 1 Step -1
    If Cells(c, 1) <> 0 Then
        MsgBox "Last day entered was day " & c
        Exit Sub
    End If
Next c
End Sub
 
Upvote 0
Not exactly what I meant. This macro returns the last row filled in row in my sheet. It needs to lookup in the arrey and return the last row that has data greater than zero or nothing in it.
 
Upvote 0
Sorry, I see what I did:
Code:
Sub MyMacro() 
Dim Limit As Long 
Dim c As Long 
Limit = Cells(Rows.Count, 2).End(xlUp).Row 
For c = Limit To 1 Step -1 
    If Cells(c, 2) <> 0 Then 
        MsgBox "Last day entered was day " & c 
        Exit Sub 
    End If 
Next c 
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,516
Messages
6,119,978
Members
448,934
Latest member
audette89

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top