Copy and paste from hidden sheet

dwool40

New Member
Joined
Apr 27, 2018
Messages
46
Office Version
  1. 365
Platform
  1. Windows
I am running the following code to copy and paste from a hidden sheet. I used macro recorder.

Rich (BB code):
Rich (BB code):
Sub test12()'
' test12 Macro
'


'
    Application.ScreenUpdating = False
    Sheets("Make Ready Board (2)").Visible = True
    Sheets("Make Ready Board (2)").Select
    Range("A2:R2").Select
    Selection.Copy
    Sheets("Make Ready Board").Select
    Range("A2:R2").Select
    ActiveSheet.Paste
    Sheets("Make Ready Board (2)").Select
    Range("G2").Select
    Application.CutCopyMode = False
    Sheets("Make Ready Board").Select
    Range("G2").Select
    Sheets("Make Ready Board (2)").Visible = False
    Application.ScreenUpdating = True

End Sub


I'm not an expert but I feel like this code can be cleaned up? Any help would be appreciated.
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
I am running the following code to copy and paste from a hidden sheet. I used macro recorder.

Code:
Sub test12()'
' test12 Macro
'


'
    Application.ScreenUpdating = False
    Sheets("Make Ready Board (2)").Visible = True
    Sheets("Make Ready Board (2)").Select
    Range("A2:R2").Select
    Selection.Copy
    Sheets("Make Ready Board").Select
    Range("A2:R2").Select
    ActiveSheet.Paste
    Sheets("Make Ready Board (2)").Select
    Range("G2").Select
    Application.CutCopyMode = False
    Sheets("Make Ready Board").Select
    Range("G2").Select
    Sheets("Make Ready Board (2)").Visible = False
    Application.ScreenUpdating = True

End Sub


I'm not an expert but I feel like this code can be cleaned up? Any help would be appreciated.
You don't need to make a sheet visible to read from it. Do all those selects after you have pasted serve a purpose?
Code:
Sub Move_Values() '


    Application.ScreenUpdating = False
    
     Sheets("Make Ready Board (2)").Range("A2:R2")=Sheets("Make Ready Board").Range("A2:R2")
 
    Application.ScreenUpdating = True


End Sub
 
Last edited:
Upvote 0
Hi dwool40,

Maybe this:

Code:
Option Explicit
Sub Macro1()

    Sheets("Make Ready Board (2)").Range("A2:R2").Copy Destination:=Sheets("Make Ready Board").Range("A2")

End Sub

Regards,

Robert
 
Upvote 0
You don't need to make a sheet visible to read from it. Do all those selects after you have pasted serve a purpose?
Code:
Sub Move_Values() '


    Application.ScreenUpdating = False
    
     Sheets("Make Ready Board (2)").Range("A2:R2")=Sheets("Make Ready Board").Range("A2:R2")
 
    Application.ScreenUpdating = True


End Sub
Switch the two sides if you are going to use mine
 
Upvote 0
You don't need to make a sheet visible to read from it. Do all those selects after you have pasted serve a purpose?
Code:
Sub Move_Values() '


    Application.ScreenUpdating = False
    
     Sheets("Make Ready Board (2)").Range("A2:R2")=Sheets("Make Ready Board").Range("A2:R2")
 
    Application.ScreenUpdating = True


End Sub

I need to keep a formula from the hidden sheet that may have been overwritten on the destination sheet.
 
Upvote 0
I need to keep a formula from the hidden sheet that may have been overwritten on the destination sheet.
Check for accuracy. The selects may now be unnecessary.
Code:
    Sheets("Make Ready Board").Range("A2:R2").Value = Sheets("Make Ready Board (2)").Range("A2:R2").Value
    Sheets("Make Ready Board").Range("A2:R2").Formula = Sheets("Make Ready Board (2)").Range("A2:R2").Formula
    
    Sheets("Make Ready Board (2)").Range("G2").Select
    Sheets("Make Ready Board").Range("G2").Select
 
Upvote 0
Hi dwool40,

Maybe this:

Code:
Option Explicit
Sub Macro1()

    Sheets("Make Ready Board (2)").Range("A2:R2").Copy Destination:=Sheets("Make Ready Board").Range("A2")

End Sub

Regards,

Robert

Worked perfectly! Thanks, Robert!
 
Upvote 0

Forum statistics

Threads
1,214,599
Messages
6,120,449
Members
448,966
Latest member
DannyC96

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