Copy and Paste Question

gvf

New Member
Joined
Apr 6, 2011
Messages
6
Hello all.

I think this is a simple question.
I want to copy an especific column and paste its values, tranposed, in any choosen cell.
The code below, recorded with excel's macro recorder, doesn't do what I want, because I want to use the cell that the mouse is currently on, prior to the execution of the macro - it is, paste transposed in that cell.
I found some insights using inputbox, but I don't want a window poping for such a simple task. Can anyone help?

Thank you in advance.

Code:
Sub PasteT()
'
' PasteT Macro
'

'
    ActiveCell.Range("A1:A6").Select
    Selection.Copy
    ActiveCell.Offset(0, 8).Range("A1").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=True
End Sub
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
does this work for you?

Code:
Sub PasteT()
'
' PasteT Macro
'
Application.DisplayAlerts = False
'
    ActiveCell.Range("A1:A6").Copy
    ActiveCell.Offset(0, 8).Range("A1").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=True
Application.DisplayAlerts = True
End Sub
 
Upvote 0
Ty for the reply.

But no, it isn't working as intended yet. I tried putting the "$" symbol in the range, but it didn't copy the right range. I think the problem is with the offset property, because I don't always want it to be 8 columns away, instead I want it anywhere the mouse is.

I don't have knowledge in VBA, but I think the macro should be like this:
- define/save the cell that is currently active, in the moment that we call the macro
- copy the range A1:A6
- paste transpose the range in the former active cell

Ty.
 
Upvote 0
ok so if I understand then change

ActiveCell.Range("A1:A6").Copy
to this

Range("A1:A6").Copy
ActiveCell.Select
 
Upvote 0

Forum statistics

Threads
1,224,616
Messages
6,179,911
Members
452,949
Latest member
beartooth91

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