Standard Module Code

adamsm

Active Member
Joined
Apr 20, 2010
Messages
444
Hi,

Any help to change the following code into a standard module code would be kindly appreciated.

Code:
<code>Private Sub Worksheet_Change(ByVal Target As Range)
  Dim n As Long
  If Not Intersect(Range("E5:E6"), Target) Is Nothing Then
    Application.ScreenUpdating = False
    If Range("E5") <> "" And Range("E6") <> "" Then
      Select Case Range("E5").Value
        Case "Customer"
          n = 3
        Case "Name"
          n = 4
        Case "City"
          n = 5
        Case "Type"
          n = 9
      End Select
      Range("C10").AutoFilter Field:=n, Criteria1:=Range("E6").Text
    Application.ScreenUpdating = True
  End If
   End If
End Sub</code>
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
It would probably be just as fast to change the AutoFilter criteria manually as opposed to trying to tie it to a stand-alone module, because you'd still need an action to call the code.
 
Upvote 0
By the way, if the value that is typed in "E6" does not exist in the sheet, how could a message be created saying the the value does not exits in the sheet?

Any help would be appreciated.
 
Upvote 0
I can't think why you'd get a message like that unless there's something else triggering it.
 
Upvote 0

Forum statistics

Threads
1,224,585
Messages
6,179,696
Members
452,938
Latest member
babeneker

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top