Input Box - I think???

jrussell

New Member
Joined
Apr 4, 2002
Messages
9
I have a worksheet with several columns of data.
I have a macro that sorts the data by a field name (Cost).
It works very well.
However, sometimes I need to sort the same sheet by a different field name, like Date Orderd.
Instead of having 2 or 3 different Macros, is there a way to modify my current Macro and have it ask me what field name to sort the worksheet by?
A co-worker said he thought it could be done with an Input Box.
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
This is what the macro looks like now.
It is very simple:

Sub SortData2()
'
' SortData2 Macro
' Macro recorded 4/28/2002 by Jerry Russell
'

'
Range("A8:G27").Select
Selection.Sort Key1:=Range("A8"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
Range("A1").Select
End Sub

Thanks for any help.

Jerry
 
Upvote 0
Try this and see if it helps
Sub SortData2()
'
' SortData2 Macro
' Macro recorded 4/28/2002 by Jerry Russell
'

Range("A8:G27").Select
Selection.Application.Dialogs(xlDialogSort).Show
Range("A1").Select
End Sub
 
Upvote 0
This does work.
It prompts me with the Sort Dialoge Box and then finishes the Macro.

I did get it to work a different way but I was having problems with validation.

I posted a new question to see if anyone had any ideas.

Can you help on that one too?

Please check it out.

Thanks,

If the data validation question is not solved, I will use your solution!

Jerry
 
Upvote 0
I thought that you would only have to pick the name of the column header from the list, validation would not be an issue, because only the column headers would be available to pick from and you would not have to type anything in, there by avoiding any possible mistakes
 
Upvote 0

Forum statistics

Threads
1,213,510
Messages
6,114,034
Members
448,543
Latest member
MartinLarkin

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