Sorting By Variable Keys
Oct 9, 2008Sorting by variable keys
I have some code in a macro:
Sorting by variable keys
I have some code in a macro:
I have a spreadsheet with column headers like, "Date" "Phone number" "Name" ect., and rows of data below. Each of these rows contains data pertaining to a prospect employee, as the purpose of the spreadsheet is to keep track of job applicants. One column is used as a 'Recruiter Sign-off' area, where the recruiter who processed the application inputs their name:
Example.png
I'm trying to automate a variation of excels sort function. However, I don't want to sort 'From A to Z.' Instead, I want to have the rows of data sorted with the 'Recruiter Sign-off' column used as the sort Key, and a selected name (of one of the recruiters) used as the sort Criteria.
I already have a userform that allows the user to select a name from a listbox. When they press confirm, the name is stored in a Public String variable, (selectedRecruiter). I'd like then like to have the rows below the column headers to be sorted based on the selected name. Example: User selects the name "Jon" from a list. The application then brings all of the applicants that 'Jon' has signed off on (those rows that contain his name) to the top rows of the range.
The workbook is shared, so I cannot use tables.
I found a code that accomplished what I want, however it also leads to a horrible system crash after a few times running it (BEX crash).
[Code] ..........
The first line of the code chooses the columns to select; all columns until there is no value. From there I need to have it sort those columns based on row 1. The problem is that the columns chosen are variable. It could be columns I:N (as shown below) or column G:Z or any other combination. (The code below was recorded if that matters at all.)
View 2 Replies View RelatedI recorded what I wanted but don't know how to generalise it so regardless of sheet name it can be sorted instead of specifically looking for "leanne final test" worksheet and sorting it by precise cells.
I have starred the section out so you don't have to focus on the rest of the code. Initally I ask for the file to be opened using WeeklyFN, would I need to use it again somehow ?
Are we limited to just the Control key to run macros?
Can I use the Alt key?
Is there a way to remap keys in Excel? I would like to remap the F1 key.
View 2 Replies View RelatedI am having trouble with the 2003 Alt keys in 2007 ..
I have 2 computers (work & home)
The work computer works fine ... when i use same files on home computer some alt key features wont work?
Example Alt E S T .... (paste special formats)
Any ideas .... I've looked at sharing / protection ... cant find anything to fix it....
It cant be protection because the paste special formats works fine with a mouse or the new 2007 Alt key commands?
Just about ready to remove and re-install...
Is it possible to create a script that will allow mimic the keypress of a keyboard?
For example, if I press the windows key and R, windows will bring up the run box and then I can type in C:Windows and press enter and it will open C:Windows.
Is it possible to have Excel do this?
This would mean I create a macro that has keypresses programmed in so I can run a command prompt and enter some details there then copy the data and paste it into Excel.
I scratched this macro to autosort on more than three keys on a cell change...but is not working:
Dim rng As Range
' Set Target Range, i.e. Range("A1, B2, C3"), or Range("A1:B3")
Set rng = Target.Parent.Range("A2:V1500")
' Only look at single cell changes
If Target.Count > 1 Then Exit Sub
' Only look at that range
If Intersect(Target, rng) Is Nothing Then Exit Sub
' Action if Condition(s) are met
' Do your thing here
rng.Sort Key1:=Range("G2"), Order1:=xlAscending, Key2:=Range("F2") _
, Order2:=xlAscending, Key3:=Range("E2"), Order3:=xlAscending, Key4:=Range("C2"), Order4:=xlAscending, Key5:=Range("B2")
, Order5:=xlAscending, Order1:=xlAscending, Header:=xlGuess, OrderCustom:=1, MatchCase:= _
False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, DataOption2 _
:=xlSortNormal, DataOption3:=xlSortNormal, DataOption4:=xlSortNormal, DataOption5:=xlSortNormal
End Sub
The error goes to Key 4 saying itīs a compilation error, argument with name doesnīt founded.
Does anyone know of any way at all to trap a function key while a userform is being shown, or will I need API for that?
Is there a way to remove a value from a collection after I've added it.
I have simplified the code I'm using to highlight what I'm trying to do.
Basically I'm adding 10 keys to a collection and want to remove the last one. There is a reason for this.
The following macro works when I run using Alt+F8+Enter
The macro also works when it is linked to a button on the worksheet.
However, it does not work when I try to use the keyboard shortcut Ctrl+Shift+P.
I've tried adding the shortcut key code into the macro -- still doesn't work.
I've tried changing the shortcut key to a different letter
I am trying to create the game of snake in VBA as practice, but I cannot find how to use the arrow keys as input. From what I have read it seems that it may not be possible, but how to change the value of a variable every time an arrow key is hit, post how to do so.
View 2 Replies View Relatedi am a rowing coach and have to enter a lot of splits every day after practice and am hoping to find a way to do it without having to use the : or . keys.
so a split like 1min. 27.5sec, displayed as 1:27.5 could be entered as 1275.
i see that there are some questions already about this but seem to just work with H:M:S and time of day, i tried but wasn't able to use these for my purpose.
another fly in this ointment is that i also enter heart rates on the same sheet so in A1 it would be splits A2 heart rate, A3 split A4 HR.....
i do this for approximately 40 rowers each day with different workouts each day so each worksheet has splits and HR in different rows and columns.
I understand the end(x1Down), but i think I am missing something. I just want to go to the next cell left, right or Up, Down from whatever cell is currently selected. How do I replicate a 1 cell move as an arrow key would do?
For some reason, when i use my arrow keys to move from cell to cell it now only scrolls my screen around....What did i do, and how do i change it back? I find it sad that i can write code and this stumped me.
View 3 Replies View RelatedWhen every I click in a excel box and try to use my arrow keys to move the box example: A3 to A4. All it does is move the page up and down or across. Is there some type of setting on that is not letting me do this. It use to allow me to. Until another employee got on it. I can not start over becouse I have months of work on this book.
View 2 Replies View RelatedI want to disable ALL shortcut key functions in my program. (i.e. if a user presses Ctrl+S it will NOT save, Ctrl+O will NOT open file, etc).
Of course I need this enabled again in something like workbook close for users to have this ability in other workbooks.
I want to know the Shortcut key for deleting a Particular sheet(s) from the excel workbook.
View 10 Replies View RelatedI finally found 'Sendkeys' and by having it press {ENTER} I was able to get my data to do what I wanted.
However now I cannot print my page. I tried everything.
Sub Macro2()
'
'
Sheets("List").Select
ActiveSheet.Cells(5 , 2).Select
Selection.Copy
[Code] ......
I can copy/paste other things just fine after the SendKeys but CANNOT PRINT!
I am working on the last step in a very long project, how to filter my data based on keys in a dictionary.
The data I am working with (in the ActiveSheet) has a list of names (in column 6). I want to add these names as keys in the dictionary and the corresponding location (in column 7) as the items. Then, I want to filter the data by each key in the dictionary, copy the filtered data, and paste it into another workbook. I have included the code I have so far. It seems to work exactly how I want as long as I'm not using the dictionary.
Attached is a protected sheet. The yellow cells are unprotected. When the use is on the cell L3, and the right arrow is clicked I want it to jump to M6 and vice verser, in other words, navigate in order from left to right. Is it possiblwe to do this?
I noticed the arrow keys will move the active cell while I have an inputbox active. This will be an issue for my users, I need them to key in data only.
Is there a command that will disable the arrow keys while the users enter the requested data?
I would like to design a button (with macros),so that users of my excel page do not need to press CONTROL+SHIFT+F1+ALT,which needs to be pressed on my firm to get the new data from a central server.
View 3 Replies View RelatedHow do I capture keys sent to Excel when my workbook is open / active?
I know when you write a macro you can assign a shortcut key combo to it, such as "Ctrl-Shift-s", but I can't find where / how Excel stores that information, and can only presume it is stored away not accessible to the coder, (ie. not by going via the macro -> properties boxes).
My issue is I want to capture a key combo, then from that call a function passing a variable dependant on the combo pressed, eg:
I'm creating a small Excel RPG where the player moves the around a blank worksheet with the walls of a maze appearing as you approach them (think dark corridors, you can see only 1 cell in all directions around you).
The players current location is shown by excel setting the activecell to the players location. Currently I have four buttons labeled Up, Down, Left and Right which the player clicks to move in the desired direction.
The testers were frequently missing the four movement buttons and this would put the activecell outside of the maze next to one of the buttons. They'd have to move it back manually.
I would like for the players to move around using the arrow keys to use the activecell, as you would normally move around a sheet... but before each movement there is a procedure that check IF the player can move in the desired direction or not (cell borders used for walls), and then once they've moved there are more procedures to check for monsters treasure chests etc.
How can I make the arrow keys trigger the macros that the Up, Down, Left and Right buttons currently trigger, and not just move the activecell?
Does anyone know the VBA equivalent to using the Shift-Arrow keys on the keyboard? I am wanting a macro to do this for me. Specifically I am wanting to use Shift-Arrow Right.
View 9 Replies View Relatedif it's possible to have a red line going across the spreadsheet while using the arrow keys it follows you down through all cells. And is there a vba coding that someone has ready written.
View 9 Replies View RelatedI am relatively new to Excel 2007 and my arrow keys do not navigate cell by cell. When I press the right or left arrow keys, my entire screen shifts to the right or left but the cursor STAYS in the cell where it was. Likewise, when I press the up or down arrow keys the screen shifts up or down but again, the cursor remains where it was. Is there an option somewhere that I need to change?
View 3 Replies View RelatedI use keyboard commands in my workbook, but I cannot seem to find one that will open a selected hyperlink.
The hyperlinks have a formula like this:
=IF(B1018<>"",HYPERLINK(CONCATENATE("I:directories", B1018),"Listen"), "")
I want to be able to arrow over to that cell and hit a button to play the file (which is contained in cell B1018 in the above example), and there doesn't seem to be a keyboard shortcut to do this.