Results 1 to 2 of 2

Thread: Help to set lastrow, lastcolumn minnimum

  1. #1
    Board Regular
    Join Date
    Nov 2017
    Post Thanks / Like
    0 Post(s)
    0 Thread(s)

    Default Help to set lastrow, lastcolumn minnimum

    Hi all

    I want to set lastrow always "> 4" and lastcolumn always ">6". I have code belovew and work well but I thinks have a better way to do. Could you have any suggession to do?

    My code is:
    Sub clear()Dim lrow As Long, lcol As Long
    Application.ScreenUpdating = False
        With Sheets("result")
        lrow = .Range("D" & .Rows.Count).End(xlUp).Row
        lcol = .Cells(4, .Columns.Count).End(xlToLeft).Column
        If lrow < 4 Then lrow = 4
        If lcol < 6 Then lcol = 6
        .Range(.Cells(4, 4), .Cells(lrow, lcol)).clear
        End With
    Application.ScreenUpdating = True
    End Sub

  2. #2
    Board Regular Michael M's Avatar
    Join Date
    Oct 2005
    South Western NSW
    Post Thanks / Like
    18 Post(s)
    2 Thread(s)

    Default Re: Help to set lastrow, lastcolumn minnimum

    I wouldnt bother trying to fix something that works well.
    You don't really the need the Screen updating lines though.
    Michael M
    The more I learn, the less I seem to know.....A Please and Thank You cost nothing !
    It's easier to debug if we can see the whole macro !
    Home 2007 & 2013

    - Posting guidelines, forum rules and terms of use

    - To download Mr Excel HTML Maker

    - Try searching for your answer first, see how

    - Read the FAQs

    - List of BB codes

    [CODE]Place Your Code Here[/CODE]

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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