Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 69
Default SendKeys "(^ {HOME})"

I have read that I should avoid using SendKeys at all cost. How else can I
get the cursor to the upper-left most cell (assume a window freeze at c3)
that would emulate the CTL + HOME keys?

The code above is not working.

Thanks.

Marco
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default SendKeys "(^ {HOME})"

Maybe...

Option Explicit
Sub testme()

Dim myRow As Long
Dim myCol As Long

With ActiveWindow
myRow = .SplitRow
myCol = .SplitColumn
End With

ActiveSheet.Cells(myRow + 1, myCol + 1).Select
'or
Application.Goto reference:=ActiveSheet.Cells(myRow + 1, myCol + 1), _
Scroll:=True

End Sub

But it can get uglier if you have hidden rows/columns at that frozen pane.

Marco wrote:

I have read that I should avoid using SendKeys at all cost. How else can I
get the cursor to the upper-left most cell (assume a window freeze at c3)
that would emulate the CTL + HOME keys?

The code above is not working.

Thanks.

Marco


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 69
Default SendKeys "(^ {HOME})"

There are...and the code below sends me to a hidden cell.

Here is more detail: the freeze is actually at X3. Columns L to W are
hidden and A to K are outside of the window. I need to end up at X3 this
time around. Next time it could be AG7.

I truely appreciate the help.

"Dave Peterson" wrote:

Maybe...

Option Explicit
Sub testme()

Dim myRow As Long
Dim myCol As Long

With ActiveWindow
myRow = .SplitRow
myCol = .SplitColumn
End With

ActiveSheet.Cells(myRow + 1, myCol + 1).Select
'or
Application.Goto reference:=ActiveSheet.Cells(myRow + 1, myCol + 1), _
Scroll:=True

End Sub

But it can get uglier if you have hidden rows/columns at that frozen pane.

Marco wrote:

I have read that I should avoid using SendKeys at all cost. How else can I
get the cursor to the upper-left most cell (assume a window freeze at c3)
that would emulate the CTL + HOME keys?

The code above is not working.

Thanks.

Marco


--

Dave Peterson

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default SendKeys "(^ {HOME})"

I might use sendkeys in this case.

But if you want...

Option Explicit
Sub testme()

Dim myRow As Long
Dim myCol As Long
Dim myCell As Range

With ActiveWindow
myRow = .SplitRow
myCol = .SplitColumn
End With

Set myCell = Nothing
On Error Resume Next
With ActiveSheet
Set myCell = .Range(.Cells(myRow + 1, myCol + 1), _
.Cells(.rows.Count, .Columns.Count)) _
.Cells.SpecialCells(xlCellTypeVisible).Cells(1)
End With
On Error GoTo 0

If myCell Is Nothing Then
'do nothing
Beep
Else
myCell.Select
End If
End Sub

Marco wrote:

There are...and the code below sends me to a hidden cell.

Here is more detail: the freeze is actually at X3. Columns L to W are
hidden and A to K are outside of the window. I need to end up at X3 this
time around. Next time it could be AG7.

I truely appreciate the help.

"Dave Peterson" wrote:

Maybe...

Option Explicit
Sub testme()

Dim myRow As Long
Dim myCol As Long

With ActiveWindow
myRow = .SplitRow
myCol = .SplitColumn
End With

ActiveSheet.Cells(myRow + 1, myCol + 1).Select
'or
Application.Goto reference:=ActiveSheet.Cells(myRow + 1, myCol + 1), _
Scroll:=True

End Sub

But it can get uglier if you have hidden rows/columns at that frozen pane.

Marco wrote:

I have read that I should avoid using SendKeys at all cost. How else can I
get the cursor to the upper-left most cell (assume a window freeze at c3)
that would emulate the CTL + HOME keys?

The code above is not working.

Thanks.

Marco


--

Dave Peterson


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 69
Default SendKeys "(^ {HOME})"

But the SendKeys is not working. Do I have the correct syntax? What could
be some of the variations I can use?

I'll try the code below, just thinking ahead.

Thanks again.

"Dave Peterson" wrote:

I might use sendkeys in this case.

But if you want...

Option Explicit
Sub testme()

Dim myRow As Long
Dim myCol As Long
Dim myCell As Range

With ActiveWindow
myRow = .SplitRow
myCol = .SplitColumn
End With

Set myCell = Nothing
On Error Resume Next
With ActiveSheet
Set myCell = .Range(.Cells(myRow + 1, myCol + 1), _
.Cells(.rows.Count, .Columns.Count)) _
.Cells.SpecialCells(xlCellTypeVisible).Cells(1)
End With
On Error GoTo 0

If myCell Is Nothing Then
'do nothing
Beep
Else
myCell.Select
End If
End Sub

Marco wrote:

There are...and the code below sends me to a hidden cell.

Here is more detail: the freeze is actually at X3. Columns L to W are
hidden and A to K are outside of the window. I need to end up at X3 this
time around. Next time it could be AG7.

I truely appreciate the help.

"Dave Peterson" wrote:

Maybe...

Option Explicit
Sub testme()

Dim myRow As Long
Dim myCol As Long

With ActiveWindow
myRow = .SplitRow
myCol = .SplitColumn
End With

ActiveSheet.Cells(myRow + 1, myCol + 1).Select
'or
Application.Goto reference:=ActiveSheet.Cells(myRow + 1, myCol + 1), _
Scroll:=True

End Sub

But it can get uglier if you have hidden rows/columns at that frozen pane.

Marco wrote:

I have read that I should avoid using SendKeys at all cost. How else can I
get the cursor to the upper-left most cell (assume a window freeze at c3)
that would emulate the CTL + HOME keys?

The code above is not working.

Thanks.

Marco

--

Dave Peterson


--

Dave Peterson



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default SendKeys "(^ {HOME})"

I took out the space character and it worked ok:

SendKeys "(^{HOME})"



Marco wrote:

But the SendKeys is not working. Do I have the correct syntax? What could
be some of the variations I can use?

I'll try the code below, just thinking ahead.

Thanks again.

"Dave Peterson" wrote:

I might use sendkeys in this case.

But if you want...

Option Explicit
Sub testme()

Dim myRow As Long
Dim myCol As Long
Dim myCell As Range

With ActiveWindow
myRow = .SplitRow
myCol = .SplitColumn
End With

Set myCell = Nothing
On Error Resume Next
With ActiveSheet
Set myCell = .Range(.Cells(myRow + 1, myCol + 1), _
.Cells(.rows.Count, .Columns.Count)) _
.Cells.SpecialCells(xlCellTypeVisible).Cells(1)
End With
On Error GoTo 0

If myCell Is Nothing Then
'do nothing
Beep
Else
myCell.Select
End If
End Sub

Marco wrote:

There are...and the code below sends me to a hidden cell.

Here is more detail: the freeze is actually at X3. Columns L to W are
hidden and A to K are outside of the window. I need to end up at X3 this
time around. Next time it could be AG7.

I truely appreciate the help.

"Dave Peterson" wrote:

Maybe...

Option Explicit
Sub testme()

Dim myRow As Long
Dim myCol As Long

With ActiveWindow
myRow = .SplitRow
myCol = .SplitColumn
End With

ActiveSheet.Cells(myRow + 1, myCol + 1).Select
'or
Application.Goto reference:=ActiveSheet.Cells(myRow + 1, myCol + 1), _
Scroll:=True

End Sub

But it can get uglier if you have hidden rows/columns at that frozen pane.

Marco wrote:

I have read that I should avoid using SendKeys at all cost. How else can I
get the cursor to the upper-left most cell (assume a window freeze at c3)
that would emulate the CTL + HOME keys?

The code above is not working.

Thanks.

Marco

--

Dave Peterson


--

Dave Peterson


--

Dave Peterson
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default SendKeys "(^ {HOME})"

Do you mean to get to the upper left cell of the Pane containing the active
cell? If so, try

Dim P As Pane
Dim N As Long
If ActiveSheet.Type = xlWorksheet Then
For N = 1 To ActiveWindow.Panes.Count
Set P = ActiveWindow.Panes(N)
If Not Application.Intersect(ActiveCell, P.VisibleRange) Is Nothing
Then
P.VisibleRange(1, 1).Select
Exit For
End If
Next N
End If


Otherwise, try

If ActiveSheet.Type = xlWorksheet Then
ActiveWindow.Panes(1).VisibleRange.Cells(1, 1).Select
End If


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)



"Marco" wrote in message
...
I have read that I should avoid using SendKeys at all cost. How else can I
get the cursor to the upper-left most cell (assume a window freeze at c3)
that would emulate the CTL + HOME keys?

The code above is not working.

Thanks.

Marco



  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 69
Default SendKeys "(^ {HOME})"

It would be the upper left cell under and to the left of the frozen
rows/column.

I tried both codes you provided and the second one takes me to the cell next
to the labels [the equivalent to A1 on a non-frozen sheet]. The other code
gave me an error at the "If not ...." line.

Thanks for your help.

"Chip Pearson" wrote:

Do you mean to get to the upper left cell of the Pane containing the active
cell? If so, try

Dim P As Pane
Dim N As Long
If ActiveSheet.Type = xlWorksheet Then
For N = 1 To ActiveWindow.Panes.Count
Set P = ActiveWindow.Panes(N)
If Not Application.Intersect(ActiveCell, P.VisibleRange) Is Nothing
Then
P.VisibleRange(1, 1).Select
Exit For
End If
Next N
End If


Otherwise, try

If ActiveSheet.Type = xlWorksheet Then
ActiveWindow.Panes(1).VisibleRange.Cells(1, 1).Select
End If


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)



"Marco" wrote in message
...
I have read that I should avoid using SendKeys at all cost. How else can I
get the cursor to the upper-left most cell (assume a window freeze at c3)
that would emulate the CTL + HOME keys?

The code above is not working.

Thanks.

Marco




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
Can someone give me "simple" instruction for creating home budget Georgiagirl Excel Discussion (Misc queries) 1 August 24th 06 11:59 PM
changing a SendKeys "(^+{home})" to a function filo666 Excel Programming 6 April 12th 05 08:32 PM
sendkeys "^v" behavior changed with the office 2003 version? Tarzan of the VisualBasic Gorillas Excel Programming 0 September 3rd 04 05:02 PM
SENDKEYS change the "Number Lock" status Kenneth Lam Excel Programming 1 May 23rd 04 12:37 PM


All times are GMT +1. The time now is 03:29 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"