J
JDaywalt
I have a workbook containing several sheet tabs. I want to include code that
allows the user to replicate or 'copy' any of these sheet tabs and place the
new sheet directly to the right of the sheet they 'copied' from. For
example, let's say the sequence of existing sheet tabs is "Jones", "Smith",
and "Taylor". If a user is on "Smith" when they perform the copy, I want the
"Smith (2)" sheet to fall directly to the right of the current "Smith" sheet.
I have tried recording a macro to copy the sheet & was planning to
substitute the actual sheet name (Smith) with the more generic 'ActiveSheet'
reference, but I don't know how to adjust for the hard-coded Sheets(5) value
that appears in the last line of code-----Here is what my recorded code looks
like right now:
Sheets("Smith").Select
Sheets("Smith").Copy Before:=Sheets(5)
How can I adjust so it performs the generic "copy directly to the right"
function based on whichever active sheet I'm on at the time code is executed?
allows the user to replicate or 'copy' any of these sheet tabs and place the
new sheet directly to the right of the sheet they 'copied' from. For
example, let's say the sequence of existing sheet tabs is "Jones", "Smith",
and "Taylor". If a user is on "Smith" when they perform the copy, I want the
"Smith (2)" sheet to fall directly to the right of the current "Smith" sheet.
I have tried recording a macro to copy the sheet & was planning to
substitute the actual sheet name (Smith) with the more generic 'ActiveSheet'
reference, but I don't know how to adjust for the hard-coded Sheets(5) value
that appears in the last line of code-----Here is what my recorded code looks
like right now:
Sheets("Smith").Select
Sheets("Smith").Copy Before:=Sheets(5)
How can I adjust so it performs the generic "copy directly to the right"
function based on whichever active sheet I'm on at the time code is executed?