Copying a column to another column

Scary123

New Member
Joined
Oct 16, 2015
Messages
11
Hi everyone,

I have a workbook where I want to be able to use a command button to select which will move data from 1 column to another in the same worksheet.

The following is what I am looking for: -

1. Copy Data that is in Column C4:C23 [Range Name is Calculations]
2. Paste Data into column A4:A23 while using paste special (Values) [Range name is Copied_Cells]
3. The Sheet name is called (Calculations)

I can do a form control and record the macro but when I change the file name I have to redo the macros.
I want to be able to change the file name and have the button work without re-doing the macro.

My file is a football league and the only thing that I want to do is get this button working if it is possible.

Mark

Football League.xlsx
AC
3PositionsRank
41311
558
61717
71616
869
91514
1047
111818
121112
1333
1411
1585
1622
171415
182020
1996
2074
211919
221010
231213
Calculations
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Is the button on the same sheet as the data?
 
Upvote 0
In that case you can use
VBA Code:
Sub Scary()
   Range("A4:A23").Value = Range("C4:C23").Value
End Sub
 
Upvote 0
No that's just the name of the macro, you can change it to whatever you want & assign it to your button.
 
Upvote 0
No that's just the name of the macro, you can change it to whatever you want & assign it to your button.
Unfortunately it does not work I have selected the active X control in development and clicked on the button then selected the area in the sheet and put the data in the VBA box
as below: -
Sub Scary()

Range("C4:C23").Value = Range("A4:A23").Value

End Sub

But when I click it I get the six circles around it then if I select the c column which is the column to be copied the button goes to a normal one but then when I select the button
nothing happens.

I'm probably doing something stupid.

Mark
 
Upvote 0
Get rid of the ActiveX button & use a Form control button instead, then simply right click the button & assign macro, then select the macro from the list.
Also the macro needs to go in a standard module & not the sheet module.
 
Upvote 0
Get rid of the ActiveX button & use a Form control button instead, then simply right click the button & assign macro, then select the macro from the list.
Also the macro needs to go in a standard module & not the sheet module.
Ive done that and went through the recording and it went to the module1 as follows: -

Sub CopyScary()
'
' CopyScary Macro
'

'
Range("Calculations[Rank]").Select
Selection.Copy
Range("A4:A23").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End Sub

It works in the one file but when I save it as another file under a different name I have to go through the same procedures of recording the macro which is what I was trying
to get out of.

Mark
 
Upvote 0
Ive done that and went through the recording and it went to the module1 as follows: -

Sub CopyScary()
'
' CopyScary Macro
'

'
Range("Calculations[Rank]").Select
Selection.Copy
Range("A4:A23").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End Sub

It works in the one file but when I save it as another file under a different name I have to go through the same procedures of recording the macro which is what I was trying
to get out of.
I replaced the details in the module1 with the following: -

Sub Scary()

Range("C4:C23").Value = Range("A4:A23").Value

End Sub

But everytime I press the button it comes with Cannot run the macro it is not available in the workbook.
 
Upvote 0

Forum statistics

Threads
1,215,419
Messages
6,124,798
Members
449,189
Latest member
kristinh

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