is there a way to ask the user how many rows he/she needs in an Excel file? And then with that information the worksheet will only show the required quantity of rows and hide every other cell, just to avoid the user to edit such cells.
As an example: It prompts how many rows I want, I type 3 rows and the excel worksheet will only have those 3 rows showing, the rest will be hidden automatically.
Thanks for your help.
I never mentioned that it was impossible, I just said that it would be counter intuitive. Try this and let me know if this works.
Public Sub HideRows()
Dim RowsToKeep As Long
RowsToKeep = CLng(InputBox("How many rows should I keep?") + 1)
With ActiveSheet
.Cells.EntireRow.Hidden = False
.Rows(RowsToKeep & ":" & .Rows.Count).EntireRow.Hidden = True
End With
End Sub
edit: Answer updated to reflect the response to comment