Link to home
Create AccountLog in
Avatar of Mistborn
Mistborn

asked on

SendKeys Question

I have inherited a worksheet that has some macros that were coded in Excel 2003 and uses the line

SendKeys "+{TAB}", -1

I am using Excel 2010 now and the code is malfunctioning and I belive it has to do with that line. I belive the +Tab is to shift to the next cell to the left but I do not know what the -1 is for. I have tried searching for what the -1 is supposed to do but cannot find it. Can anyone tell me what it is for? Thanks!
SOLUTION
Avatar of SiddharthRout
SiddharthRout
Flag of India image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of Mistborn
Mistborn

ASKER

Thanks for he reply but I am still confused. It says that the -1 should be setting a wait mode...but what is the wait mode that the -1 sets it to?
It has to be 0 or 1 and not -1

or best to use True/False

Change the code to

SendKeys "+{TAB}", True

Sid
SOLUTION
Avatar of Rory Archibald
Rory Archibald
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER CERTIFIED SOLUTION
Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
You are welcome :)

Sid
Copying the help file didn't really help at all.
Mistborn,

It appears that you resolved the problem yourself, albeit with some help from the Experts, and so while your comment will be marked with the answer Sid and rorya will share in the points.

In any event, the original C grade was wholly unwarranted; it should typically be reserved for cases where the Expert(s) gave vague and incomplete answers and then failed to reply to reasonable requests for clarification.

FWIW, I know a thing ir two about Excel, and rorya's advice to avoid SendKeys is best practice.  Also, -1 does NOT convert to False in VBA.  -1 is boolean True, 0 is boolean False, and in a type conversion any non-zero numeric value converts to the True.
 
modus_operandi
EE Admin