Macro code for pasting the cell.

bubbles2010

New Member
Joined
Jun 15, 2010
Messages
19
Hello. I am a new user. I was trying to copy the sum from sheet1 to sheet2 in the same work book with macro. I was using this code:
Range(Sheets(1).Rows(36), Sheets(1).Rows(36)).Copy Destination:=Sheets(2).Range("A36")

It works fine. The only problem is it is copying the formula, but not the actual value. I know how to reference using excel equation, but I don't want to do that. I want to use VB code.
Thank you so much.
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
I'm sure that there are more ways to do it, but here are two:
Code:
Sub firstoption()
    With Sheets(2).Rows(36)
        .Value = Sheets(1).Rows(36).Value
    End With
End Sub
Code:
Sub secondoption()
    Sheets(1).Rows(36).Copy
    Sheets(2).Rows(36).PasteSpecial Paste:=xlValues
End Sub
 
Upvote 0
I wouldn't use the With for only 1 line of code:

Code:
Sub test()
Sheets(2).Rows(36).Value = Sheets(1).Rows(36).Value
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

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