LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default Help with a Combo Box Change Event

Hello,

I only receive the follow error when I do a "Save As" for my excel document.

Run-time error '1004':
Select Method of Range Class Failed


Why do I get this error when I use "Save As" and the debugger highlights the
following line in the below code?
Range("B9").Select

Is there a way to use the sheet name instead of "ActiveSheet"?



Private Sub cmbSort_Change()

Sort_Data ActiveSheet, "1234", cmbSort.Value

End Sub


Private Sub Sort_Data(sht As Worksheet, pwd As String, val As String)

' Unprotect Worksheet
sht.Unprotect Password:=pwd

With sht
If val = "Patient Name" Then
' Sort by Status by Patient Name
With Worksheets("PatientList")
.Range("PatientData").Sort Key1:=.Range("Status"), _
Order1:=xlAscending, Key2:=.Range("Patient_Name"), _
Order2:=xlAscending, Header:=xlGuess, OrderCustom:=1, _
MatchCase:=False, Orientation:=xlTopToBottom
End With
Range("B9").Select

ElseIf val = "Discharge Date (No Status)" Then
' Sort by Discharge Date (No Status)
With Worksheets("PatientList")
.Range("PatientData").Sort Key1:=.Range("Discharge_Date"), _
Order1:=xlAscending, Key2:=.Range("Patient_Name"), _
Order2:=xlAscending, Header:=xlGuess, OrderCustom:=1, _
MatchCase:=False, Orientation:=xlTopToBottom
End With
Range("B9").Select

Else
' Sort by Assigned Counselor Initials (No Status)
With Worksheets("PatientList")
.Range("PatientData").Sort Key1:=.Range("Couns_Assigned"), _
Order1:=xlAscending, Key2:=.Range("Patient_Name"), _
Order2:=xlAscending, Header:=xlGuess, OrderCustom:=1, _
MatchCase:=False, Orientation:=xlTopToBottom
End With
Range("B9").Select

End If
End With

' Protect Worksheet
sht.Protect Password:=pwd, Scenarios:=True

End Sub


Thanks
Ruan


 
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
change event smonsmo Excel Discussion (Misc queries) 1 June 8th 07 09:31 PM
Worksheet Change event DoctorG Excel Discussion (Misc queries) 4 February 15th 06 12:53 PM
Change event? Mike Rogers Excel Discussion (Misc queries) 2 January 5th 06 01:46 AM
Change of Row event crazybass2 Excel Discussion (Misc queries) 7 December 7th 04 06:21 PM
change event/after update event?? scrabtree23[_2_] Excel Programming 1 October 20th 03 07:09 PM


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

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

About Us

"It's about Microsoft Excel"