![]() |
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 |
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 |
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. |
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. |
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. |
All times are GMT +1. The time now is 05:28 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com