Consulting

Results 1 to 4 of 4

Thread: I need the cursor to go to the last non-zero in column C

  1. #1

    I need the cursor to go to the last non-zero in column C

    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.

  2. #2
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,727
    Location
    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
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  3. #3
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    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
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  4. #4
    Thanks for your help!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •