How to copy sheet and move to front of workbook?

Mr2017

Well-known Member
Joined
Nov 28, 2016
Messages
644
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Hi

I've like to

- copy sheet 9 in a workbook
- move it to the front of the workbook
- then copy and paste everything in that sheet as values


Does anyone know how to do this, please? I know the code below will activate it then move it to the front.

The methods I've seen online copy it to a new workbook but Ito copy it and keep the copy within the workbook.



Code:
Sub FN()


Sheet9.Activate
<code class="vb plain" style="font-size: 16px; white-space: nowrap; padding: 0px !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; color: rgb(0, 0, 0) !important; border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; min-height: auto !important;">ActiveSheet.Move Before: = ActiveWorkbook.Sheets(1)</code>


End Sub
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Hey,

Try this code:

Code:
Sub FN()
Sheets("Sheet9").Select
    Sheets("Sheet9").Copy Before:=Sheets(1)
    ActiveSheet.UsedRange.Value = ActiveSheet.UsedRange.Value
End Sub
 
Upvote 0
You could even use the Macro recorder to get the bulk of the code to start with?
 
Upvote 0
Just as welshgasman says, I actually got the first 2 lines of that code from the macro recorder! The final line just converts all the used cells to values instead of formulae.
 
Upvote 0
Don't need to select
and you might want to rename it !
Code:
Sub MM1()
Sheets("Sheet9").Copy Before:=Sheets(1)
 With ActiveSheet
    .UsedRange.Value = .UsedRange.Value
    .Name = "NEW SHEET"
 End With
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,327
Messages
6,124,292
Members
449,149
Latest member
mwdbActuary

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top