Quick cut and paste ideas

9iron

New Member
Joined
May 29, 2011
Messages
5
Howdy Y'all

A1:A24 contains a list of players names.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>
<o:p> </o:p>
I’m trying to quickly fill team rosters in ColumnH by double-clicking the cells in column A.<o:p></o:p>
<o:p> </o:p>
So, double-clicking a Column A cell cuts and pastes the name to the first empty cell in Column H.

Can you guys help me do this?
<o:p> </o:p>
<o:p> </o:p>
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Hi,

Welcome to the forum

Copy the macro below (Ctrl+C), right-click in the sheet-tab, View code and paste (Ctrl+V) in the right-panel.

Try it on a test-workbook

Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    Dim LRA As Long, LRH As Long
    
    LRA = Cells(Rows.Count, "A").End(xlUp).Row
    If Not Intersect(Target, Range("A1:A" & LRA)) Is Nothing Then
        Application.EnableEvents = False
        If Range("H1") = "" Then
            LRH = 1
        Else
            LRH = Cells(Rows.Count, "H").End(xlUp).Row + 1
        End If
        Cells(LRH, 8) = Target.Value
        Target = ""
        Application.EnableEvents = True
    End If
End Sub

HTH

M.
 
Upvote 0
Welcome to the Board!

This option doesn't cut and paste (I try to avoid using Cut because of what it does to cell references) but instead highlights any player in Column A whose name already appears in column H.

1. Select the player names, then...
2003 and earlier, Format | Conditional Formatting
Cell Formula is...
=COUNTA($H:$H,A1)>0
Pick your cell highlight color, then OK

2007 and higher, Home | Conditional Formatting
New Rule (near the bottom of the list)
Pick the Formula option
Use the same formula as above, highlight to suit.

2. Right-click the sheet tab and View Code.
3. Paste this code into the blank module that appears...
Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    Dim rwLast As Long
    rwLast = Range("H" & Rows.Count).End(xlUp).Row + 1
    
    If Target.Column <> 1 Then Exit Sub
    If Target.Row > 24 Then Exit Sub
    Cells(rwLast, 8).Value = Target.Value
End Sub

Close the code window. Double-clicking any cell in A1:A24 will transfer that name to the next blank row in Column H.

Denis
 
Upvote 0
Thanks Marcelo,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>
That’s what I was looking for…I would have never figured that out.<o:p></o:p>
<o:p> </o:p>
And SydneyGeek,<o:p></o:p>
I like your method too…<o:p></o:p>
But I can’t get it to work right.<o:p></o:p>
<o:p> </o:p>
All the cells in Column A turned red with cond formatting<o:p></o:p>
When I double-click the names, they change to black font then back to red when I select another cell.<o:p></o:p>
Wonder what I'm doing wrong?
 
Upvote 0
Thanks Marcelo,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>
That’s what I was looking for…I would have never figured that out.<o:p></o:p>
<o:p></o:p>

You are welcome and tks for providing feedback :)

M.
 
Upvote 0

Forum statistics

Threads
1,224,602
Messages
6,179,844
Members
452,948
Latest member
UsmanAli786

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