VBA to Sort from a selected Cell data

kansfan2001

New Member
Joined
Aug 22, 2020
Messages
21
Office Version
  1. 365
Platform
  1. Windows
Hello,

I'm sure this is an easy one. I am looking to sort a list I have created based off of what I input into Cell B2 (shown in yellow on sorting a list jpg.). But I am not sure what I need to put at the :="Carlos" to always reflect the what is in B2 that way I can search for for Melissa and not Carlos yet not having to change the VBA each time I look for a now person on the list.



VBA Code:
Sub FindName()
'
' FindName Macro
'

'
    Range("B2").Select
    Selection.Copy
    ActiveSheet.ListObjects("FighterNames").Range.AutoFilter Field:=1, Criteria1 _
        :="Carlos"
End Sub

Thanks for the help in advance YOU ROCK!
 

Attachments

  • Sorting a List.jpg
    Sorting a List.jpg
    83.1 KB · Views: 22

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.
How about
VBA Code:
Sub FindName()
    ActiveSheet.ListObjects("FighterNames").Range.AutoFilter Field:=1, Criteria1 _
        :=Range("B2").Value
End Sub
 
Upvote 0
Solution
OHHHH boy that worked.... sorry I wasn't able to figure that one out on my own :) Excel can be frustrating at times.... thanks for the help very much appreciated
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,652
Messages
6,120,747
Members
448,989
Latest member
mariah3

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