ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Specifing the active cell (https://www.excelbanter.com/excel-programming/356904-specifing-active-cell.html)

[email protected]

Specifing the active cell
 
How can I specify what the activecell is, If I try to select a new
range (see below) this doesn't seem to change the active cell
(according to activecell.rows)

Excel.Sheets("ALLIncidents").Range("A1")

Help???


Andrew Taylor

Specifing the active cell
 
Your code doesn't select the range - you need to use

Excel.Sheets("ALLIncidents").Range("A1").Select

but first you also have to make sure that "ALLIncidents"
is the active sheet:
Excel.Sheets("ALLIncidents").Active

unless of course you know for certain that it is active - but
better safe than sorry..

As a general rule it's not usually necessary to select cells,
and it tend to make macros run slower (as well as possibly
confusing users by losing their initial selection). Instead
you can do things like:

Dim MyCell as Excel.Range
Set MyCell = Excel.Sheets("ALLIncidents").Range("A1")
MyCell.Value = "Hello, World!"


Andrew


wrote:
How can I specify what the activecell is, If I try to select a new
range (see below) this doesn't seem to change the active cell
(according to activecell.rows)

Excel.Sheets("ALLIncidents").Range("A1")

Help???




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

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