Finding the last row that contains a value, of a column

riedyp

Board Regular
Joined
Feb 13, 2020
Messages
88
Office Version
  1. 365
Platform
  1. Windows
Hello,
I am trying to select a cell in the last row that does not contain a 0. It is taking me to Row 54 but I want it to go to Row 37. The method I know is to go to a cell at the bottom of the sheet and "xlUp" so it will find the first value it finds. I want to do this but want to ignore all of the "0's" till it arrives at value "3.3" in Row 37.
Any method that would solve this would be greatly appreciated.
VBA Code:
Private Sub UpdateButton_Click()
NewRow = ActiveSheet.Cells(1000, 3).End(xlUp).Row 'Goes to the last updated cell
ActiveSheet.Cells(NewRow, 3).Select
End Sub
 

Attachments

  • Forumsnip.PNG
    Forumsnip.PNG
    31.6 KB · Views: 14

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
The only ways that I can think of to do that are to loop backwards
VBA Code:
Sub riedyp1()
Dim lRow As Long, newRow As Long
lRow = ActiveSheet.Cells(Rows.Count, 3).End(xlUp).Row
For newRow = lRow To 1 Step -1
    If ActiveSheet.Cells(newRow, 3) <> 0 Then Exit For
Next
ActiveSheet.Cells(newRow, 3).Select
End Sub
or to apply a temporary filter.
VBA Code:
Sub riedyp2()
    With ActiveSheet.Range("$C$23")
        .AutoFilter Field:=1, Criteria1:=">0", Operator:=xlFilterValues
        .EntireColumn.SpecialCells(xlVisible).Cells(Rows.Count).End(xlUp).Select
        .AutoFilter
    End With
End Sub
 
Upvote 0
Thank you for the help. I forgot to mention that it is being assigned to a button. Is there a way for this to run through all of those iterations with just one click? Because as of now if I click once it Selects C54 then another click C53 and so on.
 
Upvote 0
What else are you trying to do with the code?

For me it goes straight to C37, assigning it to a button shouldn't change that.
 
Upvote 0
All I changed was putting the code within my button. So did I do this wrong?
VBA Code:
Private Sub UpdateButton_Click()
Dim lRow As Long, newRow As Long
lRow = ActiveSheet.Cells(Rows.Count, 3).End(xlUp).Row
For newRow = lRow To 1 Step -1
    If ActiveSheet.Cells(newRow, 3) <> 0 Then Exit For
Next
ActiveSheet.Cells(newRow, 3).Select
End Sub
 
Upvote 0
Are the "0" values actually 0 or something like 0.001?
 
Upvote 0
The list is all cells that reference another column. The "0's" are the cells that do not contain a value at the moment. I am doing this to have a button to update my list to the correct amount of values that will be formatted.
 
Upvote 0
The list is all cells that reference another column. The "0's" are the cells that do not contain a value at the moment.
In that case why not find the last row from the other column?
 
Upvote 0
I think I eliminated that from my thought process because I dont know how to:
find the last row
select a range of cells from columns E,H,I,J of the "LastRow" to row 9
then put those values at row 24.

would you have a better idea of how to do this? I am doing this to create a dynamic table
 
Upvote 0
So you're just copying down from above?

If it is a direct copy then you could simply use a very simple formula and do away with the code and button.

Assuming that your existing formula in C24 is =E9 all you need to do is change it to =IF(E9="","",E9)

Somehow I suspect that it will not be that simple, but asking half of a question usually results in half of an answer.
 
Upvote 0

Forum statistics

Threads
1,214,935
Messages
6,122,337
Members
449,078
Latest member
skydd

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