hobbiton73
02-03-2013, 11:14 AM
Hi, I wonder whether someone may be able to help me please.
I'm using the code below to automatically sort a range using the 'before close' declaration.
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Sheets("Input").Protect "password", UserInterFaceOnly:=True
With ThisWorkbook.Worksheets("Input")
If .Range("B7").Value = "" Then Exit Sub
.Range("B7:AH400").Sort Key1:=.Range("B7"), _
Order1:=xlAscending, _
Header:=xlGuess, _
OrderCustom:=1, _
MatchCase:=False, _
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
End With
End Sub
The problem I'm having is that this currently sorts all the values in column "B" including pre-defined text I set for the user to tell them where to start entering a new row of data.
Could someone perhaps tell me please how I could exclude the text value "Enter your name" from the sort which takes place?
Many thanks and kind regards
Chris
I'm using the code below to automatically sort a range using the 'before close' declaration.
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Sheets("Input").Protect "password", UserInterFaceOnly:=True
With ThisWorkbook.Worksheets("Input")
If .Range("B7").Value = "" Then Exit Sub
.Range("B7:AH400").Sort Key1:=.Range("B7"), _
Order1:=xlAscending, _
Header:=xlGuess, _
OrderCustom:=1, _
MatchCase:=False, _
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
End With
End Sub
The problem I'm having is that this currently sorts all the values in column "B" including pre-defined text I set for the user to tell them where to start entering a new row of data.
Could someone perhaps tell me please how I could exclude the text value "Enter your name" from the sort which takes place?
Many thanks and kind regards
Chris