Home |
Search |
Today's Posts |
#2
![]()
Posted to microsoft.public.excel.newusers
|
|||
|
|||
![]()
"lostgrave2001" wrote:
Could anyone show me how to change the following macro to activie sheet/tab rather than having to create a new macro for every tab. [....] Do Until Worksheets("local").Cells(rwIndex, 1).Value = "" [....] ActiveSheet.Cells(rwIndex, 1).Select [....] sline = Worksheets("local").Cells(rwIndex, 1).Value [....] Range("W2") = rwIndex - 1 I have not studied your code in detail. But I suspect you entered into a worksheet object, for example by right-clicking on the worksheet tab and clicking on View Code. If that is the case, in VBA, click on Insert, then Module. Then cut (ctrl+X) the text from the sheet object and paste it into the module. You might also want to remove references to Worksheets("local"), unless your intent is to reference a worksheet that might not be the active worksheet. And the use of ActiveSheet appears to be redundant, or it needs to be changed, depending on your intent. You might need to understand the distinction among the various ways to refer to worksheets implicitly and explicitly. Suppose the code is currently in the Sheet1 object, the ActiveSheet is Sheet2, and the worksheet "local" is Sheet3. That is, there are three different worksheets involved. Then Range("W2") is equivalent to Sheet1.Range("W2"), ActiveSheet.Cells is equivalent to Sheet2.Cells, and Worksheets("local").Cells is equivalent to Sheet3.Cells. If you simply cut-and-paste the code into a normal module without change, Range("W2") will be equivalent to Sheet2.Range("W2"). All the other equivalent references would be the same. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Macro recorded... tabs & file names changed, macro hangs | Excel Worksheet Functions | |||
Macro to copy and paste values (columns)I have a macro file built | Excel Programming | |||
Macro not showing in Tools/Macro/Macros yet show up when I goto VBA editor | Excel Programming | |||
Need syntax for RUNning a Word macro with an argument, called from an Excel macro | Excel Programming | |||
Start Macro / Stop Macro / Restart Macro | Excel Programming |