Simple copy and Paste in VBA

StuartWhi

Board Regular
Joined
Sep 1, 2011
Messages
75
Hi,

This should be simple but maybe it's just me.

All I want to do is copy from one cell "F1" to the other "D1" if a third cell "F2" is = to "1".

I thought this would work but I'm missing something.

Code:
Option Explicit
Sub simple_copy()

If ("F2") = 1 Then
    .Value("D1") = ("F1")
    .Value("F1") = Clear
End If
End Sub

Thanks for your help,

Stuart.
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Code:
Sub simple_copy()  
If Range("F2") = "1" Then     Range("D1") = Range("F1") 
    Range("F1").ClearContents 
End If 
End Sub
 
Upvote 0
Hi Machopicho,

Thanks heaps for your help, had to make a slight change (remove the "End If") and it works great.

Code:
Option Explicit
Sub simple_copy()
    If Range("F2") = "1" Then Range("D1") = Range("F1")
    Range("F1").ClearContents
End Sub

Regards,

Stuart.
 
Upvote 0

Forum statistics

Threads
1,214,895
Messages
6,122,128
Members
449,066
Latest member
Andyg666

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