Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.excel
external usenet poster
 
Posts: 97
Default How to programmatically set a focus on the selected cell?

Hi,
Using Excel automation, how to set a focus (rectangle around the cell)
, by specifying Column No and Row No.?
Thanks,
Jack


  #2   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.excel
external usenet poster
 
Posts: 3,355
Default How to programmatically set a focus on the selected cell?

Cells(rownumber,columnnumber).select



"Jack" wrote:

Hi,
Using Excel automation, how to set a focus (rectangle around the cell)
, by specifying Column No and Row No.?
Thanks,
Jack



  #3   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.excel
external usenet poster
 
Posts: 3,290
Default How to programmatically set a focus on the selected cell?


Providing you have a properly declared worksheet object then...
WS.Cells(Rw, Col).Select
Rw is the row number and Col is the Column number and both
should be a Long.

Also, you do not need to Select in order to "work" on a cell, just
use the reference... WS.Cells(69, 11).Value = "Mush"
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware



"Jack" <replyto@it wrote in message ...
Hi,
Using Excel automation, how to set a focus (rectangle around the cell)
, by specifying Column No and Row No.?
Thanks,
Jack


  #4   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.excel
external usenet poster
 
Posts: 97
Default How to programmatically set a focus on the selected cell?

Thank you.
However, when I do that the
moExcelApp_SheetSelectionChange is invoked.
How can I do that (setting the focus) without invoking that function?
Jack

"Jack" <replyto@it wrote in message
...
Hi,
Using Excel automation, how to set a focus (rectangle around the
cell) , by specifying Column No and Row No.?
Thanks,
Jack



  #5   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.excel
external usenet poster
 
Posts: 97
Default How to programmatically set a focus on the selected cell?

reversing my original question:
How to remove programmatically focus (rectangle) from the cell?
Jack

"Jack" <replyto@it wrote in message
...
Hi,
Using Excel automation, how to set a focus (rectangle around the
cell) , by specifying Column No and Row No.?
Thanks,
Jack





  #6   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.excel
external usenet poster
 
Posts: 3,290
Default How to programmatically set a focus on the selected cell?


Again ...
You don't have to select the cell. Also, you do not have to
select the sheet. WS.Cells(69, 11).Value = "Mush" will work from
almost anywhere. No selection then no selection change event occurs.

However, to prevent events from occurring use
moExcelApp.EnableEvents = False.
Events remain off until reset to True by your code.
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware



"Jack" <replyto@it wrote in message
Thank you.
However, when I do that the
moExcelApp_SheetSelectionChange is invoked.
How can I do that (setting the focus) without invoking that function?
Jack

"Jack" <replyto@it wrote in message
...
Hi,
Using Excel automation, how to set a focus (rectangle around the
cell) , by specifying Column No and Row No.?
Thanks,
Jack



  #7   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.excel
external usenet poster
 
Posts: 97
Default How to programmatically set a focus on the selected cell?

Thank you very much
This works for me:
moExcelApp.EnableEvents = False
moExcelApp.Cells(CurrentRow, CurrentCol).Select
moExcelApp.EnableEvents = True

I do not understand the first part:
When I tried:
moExcelApp.Cells(69,11).Value = "Mush"
the event moExcelApp_SheetChange is fired.
Jack

"Jim Cone" wrote in message
...

Again ...
You don't have to select the cell. Also, you do not have to
select the sheet. WS.Cells(69, 11).Value = "Mush" will work from
almost anywhere. No selection then no selection change event occurs.

However, to prevent events from occurring use
moExcelApp.EnableEvents = False.
Events remain off until reset to True by your code.
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware



"Jack" <replyto@it wrote in message
Thank you.
However, when I do that the
moExcelApp_SheetSelectionChange is invoked.
How can I do that (setting the focus) without invoking that function?
Jack

"Jack" <replyto@it wrote in message
...
Hi,
Using Excel automation, how to set a focus (rectangle around the
cell) , by specifying Column No and Row No.?
Thanks,
Jack





  #8   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.excel
external usenet poster
 
Posts: 35,218
Default How to programmatically set a focus on the selected cell?

You can turn off event handling before you make the change, then make the
changes, then turn the event handling back on.

moExcelApp.EnableEvents = False
moExcelApp.Cells(69,11).Value = "Mush"
moExcelApp.EnableEvents = True

Jack wrote:

Thank you very much
This works for me:
moExcelApp.EnableEvents = False
moExcelApp.Cells(CurrentRow, CurrentCol).Select
moExcelApp.EnableEvents = True

I do not understand the first part:
When I tried:
moExcelApp.Cells(69,11).Value = "Mush"
the event moExcelApp_SheetChange is fired.
Jack

"Jim Cone" wrote in message
...

Again ...
You don't have to select the cell. Also, you do not have to
select the sheet. WS.Cells(69, 11).Value = "Mush" will work from
almost anywhere. No selection then no selection change event occurs.

However, to prevent events from occurring use
moExcelApp.EnableEvents = False.
Events remain off until reset to True by your code.
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware



"Jack" <replyto@it wrote in message
Thank you.
However, when I do that the
moExcelApp_SheetSelectionChange is invoked.
How can I do that (setting the focus) without invoking that function?
Jack

"Jack" <replyto@it wrote in message
...
Hi,
Using Excel automation, how to set a focus (rectangle around the
cell) , by specifying Column No and Row No.?
Thanks,
Jack




--

Dave Peterson
  #9   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.excel
external usenet poster
 
Posts: 35,218
Default How to programmatically set a focus on the selected cell?

Something has to be selected. You could select a different range (out of the
visible area???) or select an object.

But I think Jim's point was that if you don't include .select's in your code,
you don't have to worry about going back to where you started.

Jack wrote:

reversing my original question:
How to remove programmatically focus (rectangle) from the cell?
Jack

"Jack" <replyto@it wrote in message
...
Hi,
Using Excel automation, how to set a focus (rectangle around the
cell) , by specifying Column No and Row No.?
Thanks,
Jack


--

Dave Peterson
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 - Selected Cell highlight on focus loss. Jack Excel Discussion (Misc queries) 0 August 11th 08 10:03 PM
Excel selected range not showing when Excel application not in focus ewolfman Excel Discussion (Misc queries) 0 January 9th 07 10:40 PM
How to set programmatically focus on specified Excel row? Jack Excel Programming 7 February 9th 06 07:52 AM
Macro to take selected cells times a selected cell Craig Excel Programming 4 October 24th 05 12:54 AM
Return action when a selected cell has focus. Paul Excel Programming 3 November 22nd 04 04:51 PM


All times are GMT +1. The time now is 03:23 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"