Sub HideRowsCols()
Application.ScreenUpdating = False
Dim LastRow As Long, lCol As Long, fRow As Long, lRow As Long, fCol As Long, lColumn As Long
lColumn = ActiveSheet.UsedRange.Columns.Count
LastRow = Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
With Selection
fRow = .Cells(1, 1).Row
lRow = .Cells(.Rows.Count, .Columns.Count).Row
fCol = .Cells(1, 1).Column
lCol = .Cells(.Rows.Count, .Columns.Count).Column
End With
If fCol > 1 Then Range(Columns(1), Columns(fCol - 1)).EntireColumn.Hidden = True
If lColumn > lCol Then Range(Cells(1, lCol + 1), Cells(1, lColumn)).EntireColumn.Hidden = True
If fRow > 1 Then Rows("1:" & fRow - 1).Hidden = True
If LastRow > lRow Then Rows(lRow + 1 & ":" & LastRow).Hidden = True
Application.ScreenUpdating = True
End Sub