PDA

View Full Version : I need the cursor to go to the last non-zero in column C



ghostbroker2
12-07-2017, 06:57 AM
I've got a macro for printing out labels.
But after excel captures the information and prints the label, I need the cursor to go back to the last non-zero in column C.
I wrote this macro with the macro recorder. So, I know that I'll have to hard-code this last function.
But I don't know how to do that in VBA.
Any help is appreciated.

Paul_Hossler
12-07-2017, 07:31 AM
Last non-ZERO or last non-BLANK?

This fragment goes to the last non-blank cell in column C



Option Explicit

Sub LastNonBlank()
With ActiveSheet
Application.Goto .Cells(.Rows.Count, 3).End(xlUp)
End With
End Sub

SamT
12-07-2017, 07:50 AM
Snippet

Dim Cel As Range
Set Cel = Cells(Rows.Count, "C").End(xlUp)
Do While (Not IsNumeric(Cel)) Or Cel = 0
Set Cel = Cel.Offset(-1)
Loop
Application.GoTo Cel

ghostbroker2
12-07-2017, 09:34 AM
Thanks for your help!