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

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
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,224,818
Messages
6,181,152
Members
453,021
Latest member
Justyna P

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