VBA Noob, PasteSpecial problems

Sarkonis

New Member
Joined
Jul 2, 2018
Messages
8
Hi Folks,

Complete VBA Noob here. Been reading these forums for a long time. Finally found a topic I can't find anywhere.

I've got a number of frozen panes at the top of a spreadsheet referencing the active row of the same sheet.

I've used this code to transpose my active cells to the top.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Range("A" & (ActiveCell.Row)).Copy Destination:=Range("A3")
Range("B" & (ActiveCell.Row)).Copy Destination:=Range("B3")
Range("C" & (ActiveCell.Row)).Copy Destination:=Range("C3")
End Sub


The problem I'm having is that Column C is calculated by a formula. I understand I have to use PasteSpecial to bring the value and not the formula, but I can't seem to make it work.

Help?

much thanks!
 

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.
Perhaps:

Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Row = 3 Then Exit Sub
Application.EnableEvents = False
    Range("A" & ActiveCell.Row).Resize(, 2).Copy Range("A3")
    Range("C" & ActiveCell.Row).Copy
    Range("C3").PasteSpecial xlPasteValues
    Application.CutCopyMode = False
    Target.Select
Application.EnableEvents = True
End Sub
 
Upvote 0
It works!

I don't understand why it works, or how Column B is still copying to the top, but it works!
I assume that column B has something to do with the .resize(, 2)

Many thanks!
 
Upvote 0
It's copying both columns at the same time.
It's taking column A resizing it to 2 columns to grab column B and then pasting both columns starting at A3
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,195
Members
452,616
Latest member
intern444

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