Hi,
When I select one or more cells in a single row,
I want to be able to click a button to copy the values from the same columns in Row 10 to the selection.
Edit: For clarification the selection will contain only adjacent cells.
Thanks
Printable View
Hi,
When I select one or more cells in a single row,
I want to be able to click a button to copy the values from the same columns in Row 10 to the selection.
Edit: For clarification the selection will contain only adjacent cells.
Thanks
I tinkered with it until I got it figured :)
[vba]
Option Explicit
Private Sub CommandButton2_Click()
Dim rng As range
Set rng = Cells(10, Selection.Column).Resize(, Selection.Columns.Count)
rng.Copy Cells(Selection.Row, Selection.Column)
End Sub
[/vba]
It eventually dawned on me that I only need one line,
plus I figured I'd share how I'm doing the opposite.
[vba]
Private Sub CommandButton1_Click()
'( Copy Row 10 corresponding cells to a single row range selected )
Cells(10, Selection.Column).Resize(, Selection.Columns.Count).Copy Selection
End Sub
[/vba]
opposite
[vba]
Private Sub CommandButton2_Click()
'( Copying Selection in single row to row 10 )
Selection.Copy Cells(10, Selection.Column)
End Sub
[/vba]