Moving info from a worksheet to another using a button

mattbird

Active Member
Joined
Oct 15, 2013
Messages
285
Office Version
  1. 2016
Hi,

I am trying to copy info from one worksheet to another when i click a button. Both worksheets have exactly the same lay out and range. The range I am trying to move from worksheet 1 is A1:O45 to worksheet 2 A1:O45.

Can anyone help me write a VBA for this?

Thanks
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Hi,

I have try the following code which works but it copies the formulas and filters and colour. I would like it to only copy the figures in the cells if this is possible.

Code:
Sub Archive_Stats_TextBox1_Click()
Sheets("MATT 2 Stats").Range("A1:O45").Copy Sheets("PFA Archive").Range("A1")
End Sub
 
Upvote 0
Hi,

I have try the following code which works but it copies the formulas and filters and colour. I would like it to only copy the figures in the cells if this is possible.

Code:
Sub Archive_Stats_TextBox1_Click()
Sheets("MATT 2 Stats").Range("A1:O45").Copy Sheets("PFA Archive").Range("A1")
End Sub

Try recording the macro but copy / paste values the info on the new sheet instead of copying the entire sheet if you don't want the formatting and formulas.
 
Upvote 0
Try this:
Code:
Sub Copy_Data()
Sheets(2).Range("A1:O45").Value = Sheets(1).Range("A1:O45").Value
End Sub
 
Upvote 0
Mattbird.
Not sure who's script your using but the one I posted does not copy formats and formulas. I have tested this myself.
 
Upvote 0
mattbird,

Was trying to respond to your 'second' thread but prevented.
mattbird,

Two possibilities, assuming that you have no need to copy anything other than values e.g. no formatting etc, Paste Special or just assign Value
Code:
Sub Archive_Stats_TextBox1_Click()
With Worksheets("Archived Stats")
    .Unprotect Password:="fiss"


Sheets("MATT 2 Stats").Range("A1:O45").Copy
Sheets("Archived Stats").Range("A2").PasteSpecial Paste:=xlPasteValues


   .Protect Password:="fiss"
    End With
End Sub


 'OR...


Sub Archive_Stats_TextBox1_Click()
With Worksheets("Archived Stats")
    .Unprotect Password:="fiss"


Sheets("Archived Stats").Range("A2:O46") = Sheets("MATT 2 Stats").Range("A1:O45").Value


   .Protect Password:="fiss"
    End With
End Sub

Hope that helps.
 
Upvote 0
I don't understand why my suggestion in post #6 above does not work. It should be obvious you could change Sheets(1) to Sheets("MATT 2 Stats") if you want.
In his op he did not give the sheet names.

If the op does not know how to use the recorder he/she may not know how to install the script.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,203,069
Messages
6,053,352
Members
444,655
Latest member
didr

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