Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Move active cell through current selection

Is there a way to move the active cell through the current selection using
an external program? I'm trying to get a data capture program I have
written to update the active worksheet's cells. I would like the user to
select the cells to be updated, then my program will hopefully update the
active cell then move to the next cell in the selection the same way the tab
key does.

The following code shows my problem. The Goto method changes the selection
and doesn't do the same thing the tab key does.

' Get Excel instances
Set a = GetObject(, "Excel.Application")

' Set text of active cell
e.ActiveCell.Value = "Hello, World!"

e.Goto e.ActiveCell.Next


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Move active cell through current selection


use a for each something like this...

Dim rng as Range
'Get Excel instances
Set a = GetObject(, "Excel.Application")

for each rng in a.Selection
rng.value = rng.address
next rng
--
HTH...

Jim Thomlinson


"Mike King" wrote:

Is there a way to move the active cell through the current selection using
an external program? I'm trying to get a data capture program I have
written to update the active worksheet's cells. I would like the user to
select the cells to be updated, then my program will hopefully update the
active cell then move to the next cell in the selection the same way the tab
key does.

The following code shows my problem. The Goto method changes the selection
and doesn't do the same thing the tab key does.

' Get Excel instances
Set a = GetObject(, "Excel.Application")

' Set text of active cell
e.ActiveCell.Value = "Hello, World!"

e.Goto e.ActiveCell.Next



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Move active cell through current selection

Dim rng as Range
'Get Excel instances
Set a = GetObject(, "Excel.Application")

for each rng in a.Selection
rng.value = rng.address
next rng


Thank you for your help.

With this approach the active cell does not change.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Move active cell through current selection

With this approach the active cell does not change.

Your correct the active cell doesn't change but what the code does is loop
through each cell of the selected range and is no need to select the cell
(make it the active cell) to manipulate the data in it.

Mike

"Mike King" wrote:

Dim rng as Range
'Get Excel instances
Set a = GetObject(, "Excel.Application")

for each rng in a.Selection
rng.value = rng.address
next rng


Thank you for your help.

With this approach the active cell does not change.



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Move active cell through current selection


"Mike H" wrote in message
...
With this approach the active cell does not change.


Your correct the active cell doesn't change but what the code does is loop
through each cell of the selected range and is no need to select the cell
(make it the active cell) to manipulate the data in it.


I didn't explain why move the active cell is important to me.

I found my solution. I'm going to determine the next cell in the selection
using an IEnumVARIANT interface and set the active cell by calling the
Activate method.

Thanks for pointing me in the right direction.




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
Name of the current pivottable from active cell [email protected] Excel Programming 2 February 11th 08 09:45 AM
How to add todays date (static) to the current active cell using m JimmyJam75 Excel Discussion (Misc queries) 5 September 6th 06 11:23 AM
Populate current active cell - Help Please!! Larry Excel Worksheet Functions 0 July 19th 06 10:19 PM
Inesert value of column B of the current row into active cell PPL[_2_] Excel Programming 4 March 5th 06 08:13 PM
Identify current active cell reades Excel Worksheet Functions 6 January 10th 06 12:48 PM


All times are GMT +1. The time now is 11:35 PM.

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

About Us

"It's about Microsoft Excel"