Help to set lastrow, lastcolumn minnimum

sbv1986

Board Regular
Joined
Nov 2, 2017
Messages
87
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:
Code:
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

Thanks./.
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
I wouldnt bother trying to fix something that works well.
You don't really the need the Screen updating lines though.
 
Upvote 0

Forum statistics

Threads
1,223,958
Messages
6,175,633
Members
452,661
Latest member
Nonhle

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