Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default Excel VBA Sorting Error

I have a file that I want the user to click an insert button and not
be able to insert rows. I have protected the sheet, except for the
area they can enter data into and have created another Sort button.
My code keeps errors at the sort stage. Any help is appreciated.

Private Sub NFP_Sort_Click()
Const PWORD As String = "123456"
Application.ScreenUpdating = False
With Worksheets("Southeast - NFP")
.Select
.Unprotect Password:=PWORD
.Range("NFP_Sort").Select
.Sort Key1:=Range("Q7"), Order1:=xlDescending,
Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom,
_
DataOption1:=xlSortNormal
.Range("Total_NFP").Select
.Protect Password:=PWORD
End With
Application.ScreenUpdating = False
End Sub

Thanks,
Scott
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Excel VBA Sorting Error

Check your first post.

Scott Halper wrote:

I have a file that I want the user to click an insert button and not
be able to insert rows. I have protected the sheet, except for the
area they can enter data into and have created another Sort button.
My code keeps errors at the sort stage. Any help is appreciated.

Private Sub NFP_Sort_Click()
Const PWORD As String = "123456"
Application.ScreenUpdating = False
With Worksheets("Southeast - NFP")
.Select
.Unprotect Password:=PWORD
.Range("NFP_Sort").Select
.Sort Key1:=Range("Q7"), Order1:=xlDescending,
Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom,
_
DataOption1:=xlSortNormal
.Range("Total_NFP").Select
.Protect Password:=PWORD
End With
Application.ScreenUpdating = False
End Sub

Thanks,
Scott


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Excel VBA Sorting Error

Scott,

You cannot sort a worksheet - you can sort a range on a worksheet. So, change

.Sort

to

Selection.Sort


HTH,
Bernie
MS Excel MVP


"Scott Halper" wrote in message
...
I have a file that I want the user to click an insert button and not
be able to insert rows. I have protected the sheet, except for the
area they can enter data into and have created another Sort button.
My code keeps errors at the sort stage. Any help is appreciated.

Private Sub NFP_Sort_Click()
Const PWORD As String = "123456"
Application.ScreenUpdating = False
With Worksheets("Southeast - NFP")
.Select
.Unprotect Password:=PWORD
.Range("NFP_Sort").Select
.Sort Key1:=Range("Q7"), Order1:=xlDescending,
Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom,
_
DataOption1:=xlSortNormal
.Range("Total_NFP").Select
.Protect Password:=PWORD
End With
Application.ScreenUpdating = False
End Sub

Thanks,
Scott



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Excel VBA Sorting Error

untested but try this withOUT selections. Notice the . in front of
range("q7")
Private Sub NFP_Sort_Click()
Const PWORD As String = "123456"
Application.ScreenUpdating = False
With Worksheets("Southeast - NFP")
.Unprotect Password:=PWORD
.Range("NFP_Sort").Sort Key1:=.Range("Q7"), Order1:=xlDescending,
_
Header:=xlGuess,Orientation:=xlTopToBottom
.Protect Password:=PWORD
End With
Application.ScreenUpdating = TRUE
End Sub


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Scott Halper" wrote in message
...
I have a file that I want the user to click an insert button and not
be able to insert rows. I have protected the sheet, except for the
area they can enter data into and have created another Sort button.
My code keeps errors at the sort stage. Any help is appreciated.

Private Sub NFP_Sort_Click()
Const PWORD As String = "123456"
Application.ScreenUpdating = False
With Worksheets("Southeast - NFP")
.Select
.Unprotect Password:=PWORD
.Range("NFP_Sort").Select
.Sort Key1:=Range("Q7"), Order1:=xlDescending,
Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom,
_
DataOption1:=xlSortNormal
.Range("Total_NFP").Select
.Protect Password:=PWORD
End With
Application.ScreenUpdating = False
End Sub

Thanks,
Scott


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Excel VBA Sorting Error

As Dave said, "check your first post". I will add "Patience is a VIRTUE"

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Don Guillett" wrote in message
...
untested but try this withOUT selections. Notice the . in front of
range("q7")
Private Sub NFP_Sort_Click()
Const PWORD As String = "123456"
Application.ScreenUpdating = False
With Worksheets("Southeast - NFP")
.Unprotect Password:=PWORD
.Range("NFP_Sort").Sort Key1:=.Range("Q7"), Order1:=xlDescending,
_
Header:=xlGuess,Orientation:=xlTopToBottom
.Protect Password:=PWORD
End With
Application.ScreenUpdating = TRUE
End Sub


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Scott Halper" wrote in message
...
I have a file that I want the user to click an insert button and not
be able to insert rows. I have protected the sheet, except for the
area they can enter data into and have created another Sort button.
My code keeps errors at the sort stage. Any help is appreciated.

Private Sub NFP_Sort_Click()
Const PWORD As String = "123456"
Application.ScreenUpdating = False
With Worksheets("Southeast - NFP")
.Select
.Unprotect Password:=PWORD
.Range("NFP_Sort").Select
.Sort Key1:=Range("Q7"), Order1:=xlDescending,
Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom,
_
DataOption1:=xlSortNormal
.Range("Total_NFP").Select
.Protect Password:=PWORD
End With
Application.ScreenUpdating = False
End Sub

Thanks,
Scott





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
sorting error JT Excel Programming 2 September 16th 05 02:37 PM
sorting error ananga Excel Discussion (Misc queries) 2 June 30th 05 04:21 PM
sorting error abstsogds Excel Worksheet Functions 2 December 6th 04 07:19 PM
error in sorting hans[_3_] Excel Programming 1 April 22nd 04 11:09 AM


All times are GMT +1. The time now is 07:36 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"