lookup macro

Gazlar

Board Regular
Joined
Aug 3, 2012
Messages
101
Office Version
  1. 365
Platform
  1. Windows
Is there a way that I can create a macro that will put colum A and B in ascending order, And lookup E2 with the answer in E3.

Im aware that for the lookup function to work correctly colum A needs to be numerical order.

I have set up colum A and colum b in Auto filter which enables me to sort colum A descending but I would like a button (macro) to do this for me so all I need to do is click the button with assigned macro to do a lookup search for me.

A l B l C l D l E l
1 l Number l Regarding l l Search l
2l0123456 l burt l l # l 01234565
3l0124567 l stan l l Regarding l Burt

Not sure if thats good enough but thats the general idea of the work sheet.
I would also like to be able to add name and to the list without having to scroll down the page each time.

Thanks
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Hello Gazler,

Set this to your button. You may want to try it in a new worksheet to get it to your specs. Luckily I had this lying around.

Private Sub CommandButton1_Click()
Range("A1:B5").Select
Selection.Sort Key1:=Range("A1"), Order1:=xlAscending, Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Range("A1").Select
End Sub

This is for column A and B. It's only for the first 5 rows but you can set it to the end of the worksheet or max rows you need. Hopefully this gets you started!
 
Upvote 0
Use Vlookup instead of Lookup. If you specify finding an exact match for Vlookup then the sort order of the data isn't important. It is only required for the function to determine an approximate match.

To go to the bottom of the data to add a new entry simply call the following macro from a button or shape.

Code:
Sub go_to_bottom()
    Range("A" & Rows.Count).End(xlUp).Offset(1, 0).Select
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,561
Messages
6,120,228
Members
448,951
Latest member
jennlynn

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