Absolutely, it's possible. However, the ease of doing so depends heavily on
the specifics, such as how much worksheet switching did you record and
whether you've got formulas that reference other worksheets. Let's try the
simplest approach first. Open the workbook containing the macro and switch
to the
VB Editor (alt + F11).
In the Project Explorer (probably at the top left; if it's not visible, View
Project Explorer), double click on Modules if necessary so that Module1 is
visible. Click on Module1 (or whichever module contains your macro). Then
seach the macro for a statement like:
Sheets("Sheet2").Select
Is there only one like that? If so, just comment it out by adding an
apostrophe before the statement:
'Sheets("Sheet2").Select
If there are multiple lines like that, with different sheets selected, we'll
have a little more work to do. And if there are formulas that reference the
worksheet (ex: =sum(Sheet2!A1), more work still.
If this simple approach doesn't cut it, please provide more detail,
especially about which sheet(s) you're switching between and what formulas in
the macro contain worksheet references.
"Andrew B" wrote:
I'm trying to get a macro I've designed to run on any worksheet.
However, when I start the macro it errors and needs to be on a worksheet
that has the same name as the one I designed it on.
Is there any way to get the macro to run on a worksheet, regartdless of what
the name is?