It's not Range("ActiveCell").Select(), it's
ActiveCell.Select()
or
ActiveCell.Activate().
2007-11-20 10:15:05
·
answer #1
·
answered by Kaptain Krakatoa 3
·
0⤊
0⤋
Many people who use Excel on a regular basis quickly realize that they perform the same, or similar, task repeatedly. This might be copying the formula in one cell to another, or saving the current value of a cell in some other cell, or adding new data to a set of existing data. It could be applying the same format, or conditional format to multiple cells, or formatting each new chart so that all charts have a similar look such as an organizational template. In each instance, the solution is to use some type of program, often called a macro, written in the Visual Basic for Applications (VBA) programming language.
To help get started, or to get the correct code and syntax for most tasks, Excel has an excellent 'macro recorder' facility that converts user actions into VBA code. This facility can help someone new to programming quickly develop easy macros. Its use is not restricted to the new programmer. It is often used by experienced developers to get 'starter' code for a particular task. That way, the developer doesn't have to memorize the nitty-gritty syntactical details.
Effectively, the code above duplicated the user's actions including the selection of each of the cells, A1 and AA1 and the scrolling to the right. While this accomplishes the task of copying the contents of cell A1 into cell AA1 and is an excellent way to get started, there are two problems with it. First, the macro is specific to cells A1 and AA1. Suppose the idea is to copy the contents of some cell in column A into the corresponding cell in column AA. How, then, would one modify the above macro to allow such flexibility? The second problem lies in the various select and scroll operations. With them, Excel correctly duplicates the user's actions. However, when the macro is run, Excel must update the visual display on the screen. Refreshing the screen is both unnecessary and wasteful. It also slows down the execution of the macro..
There are several ways. You can also use the Object Browser availble in the VBE. Press F2 to access the Object Browser, then choose Excel from the Libraries/Workbooks drop-down list. The list on the left shows all the Excel objects. When you select an object, its corresponding properties and methods appear in the list on the right.
The on-line help system for VBA is very extensive, and lists the properties and methods available for every object. The easiest way to access this is to enter the object in your VBA module and move the cursor anywhere within the object name. Press F1, and you’ll get the help topic appropriate for the object
http://www.math.vu.nl/obp/edu/project-obp/VBA-intro.pdf
2007-11-21 09:20:43
·
answer #2
·
answered by Meili Wong 2
·
0⤊
0⤋
I am assuming from your post that you are referring to Excel, correct? If you could provide more of the actual code to look at, I may be able to help you out.
2007-11-20 18:12:54
·
answer #3
·
answered by Anonymous
·
0⤊
0⤋