There are a few ways to run a macro in another sheet from whichever sheet.
will put Hallo in cell A1 in the active sheet, in other words the sheet that is visible. Can be any sheet
Will put Hallo in cell A1 in Sheet2 only. Macro can be run from any sheet.
Will put Hallo in cell A1 in Sheet2 only. Macro can be run from any sheet.
It is often required to use the reference multiple times in one line.
For instance
Following is an example from Smallman. Notice the use of ws multiple times.
The following is from
http://msdn.microsoft.com/en-us/library/wc500chb.aspx
By using With...End With, you can perform a series of statements on a specified object without
specifying the name of the object multiple times. Within a With statement block, you can specify a
member of the object starting with a period, as if the With statement object preceded it.
For example, to change multiple properties on a single object, place the property assignment
statements inside the With...End With block, referring to the object only once instead of once for each
property assignment.
If your code accesses the same object in multiple statements, you gain the following benefits by using
the With statement:
You don't need to evaluate a complex expression multiple times or assign the result to a temporary
variable to refer to its members multiple times.
You make your code more readable by eliminating repetitive qualifying expressions.
Bookmarks