ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VB TAB doesn't move activecell?? (https://www.excelbanter.com/excel-programming/320969-vbulletin-tab-doesnt-move-activecell.html)

Ben W

VB TAB doesn't move activecell??
 
Hi,

I'm using the SendKeys ["{tab}"] command in Excel 97 VB. The problem
I have is that the activecell doesn't move accross with cursor, it
stays on the same cell. For example if my cursor is on cell A1 and I
press tab, I move to cell B1 and that's my new active cell. If I do
the same but using VB and the SendKeys ["{tab}"] command, the cursor
moves but my activecell remains as A1.
I can't use an offset as my cursor may need to go down instead of
accross depending on what I've selected. That's why I'm using the TAB
command as it will only go through the selection I've highlighted.

I would appreciate any help!!

Thanks in anticipation,

Ben

Tom Ogilvy

VB TAB doesn't move activecell??
 
Possibly

Sub tester1()
For Each cell In Selection
cell.Activate
Next
End Sub

depends on what you are doing.

--
Regards,
Tom Ogilvy

"Ben W" wrote in message
om...
Hi,

I'm using the SendKeys ["{tab}"] command in Excel 97 VB. The problem
I have is that the activecell doesn't move accross with cursor, it
stays on the same cell. For example if my cursor is on cell A1 and I
press tab, I move to cell B1 and that's my new active cell. If I do
the same but using VB and the SendKeys ["{tab}"] command, the cursor
moves but my activecell remains as A1.
I can't use an offset as my cursor may need to go down instead of
accross depending on what I've selected. That's why I'm using the TAB
command as it will only go through the selection I've highlighted.

I would appreciate any help!!

Thanks in anticipation,

Ben




Harald Staff

VB TAB doesn't move activecell??
 
Hi Ben

SendKeys is very very vulnerable. See if you can use one of these:

Sub GoNext()
ActiveCell.Next.Activate
End Sub

Sub GoDown()
ActiveCell.Offset(1, 0).Activate
End Sub

HTH. Best wishes Harald

"Ben W" skrev i melding
om...
Hi,

I'm using the SendKeys ["{tab}"] command in Excel 97 VB. The problem
I have is that the activecell doesn't move accross with cursor, it
stays on the same cell. For example if my cursor is on cell A1 and I
press tab, I move to cell B1 and that's my new active cell. If I do
the same but using VB and the SendKeys ["{tab}"] command, the cursor
moves but my activecell remains as A1.
I can't use an offset as my cursor may need to go down instead of
accross depending on what I've selected. That's why I'm using the TAB
command as it will only go through the selection I've highlighted.

I would appreciate any help!!

Thanks in anticipation,

Ben





All times are GMT +1. The time now is 03:38 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com