HairyHippy
Programmer
Apologies but this is a repost of a thread I started in the wrong forum but I thought I might find the answer quicker in here by reposting the question:
I have named a group of cells "Travel". They are currently empty and will be filled in by the users. I want the users to be able to add rows but the sheet is protected. I have written the code, so that it unprotects.
The problem is that Row 21 is currently the bottom row of the "Travel" range but it won't always be. This wouldn't be a problem but on the same sheet (and must remain there) there is a section called "Entertainment" that I need to do the same thing with. So what I need is a piece of code that looks at the range "Travel" and automatically selects the last row in that range.
I have named a group of cells "Travel". They are currently empty and will be filled in by the users. I want the users to be able to add rows but the sheet is protected. I have written the code, so that it unprotects.
Code:
Sub InsertTravel()
Application.ScreenUpdating = False
ActiveSheet.Unprotect "****"
Rows("21:21").Select
Selection.Copy
Rows("22:22").Select
Selection.Insert Shift:=xlDown
Selection.Borders(xlEdgeTop).LineStyle = xlNone
Range("B22").Select
ActiveSheet.Protect "****"
Application.ScreenUpdating = True
End Sub
The problem is that Row 21 is currently the bottom row of the "Travel" range but it won't always be. This wouldn't be a problem but on the same sheet (and must remain there) there is a section called "Entertainment" that I need to do the same thing with. So what I need is a piece of code that looks at the range "Travel" and automatically selects the last row in that range.