Ajryan88 gave me the following code, I would like to make it so that I can use it using a keyboard shortcut, not a "Command Button"

Could anyone perhaps explain how I can do that?

Thanks



Private Sub CommandButton1_Click()
    Dim rng As Range
    Dim tmp
    Dim i As Integer
    
    'Make sure there are only 2 ranges selected
    If Selection.Areas.Count = 2 Then
        'Make sure each range has the same number of cells AND columns
        '(If cells and columns are the same, then it follows logically that rows are equal too)
        If Selection.Areas(1).Cells.Count = Selection.Areas(2).Cells.Count And Selection.Areas(1).Columns.Count = Selection.Areas(2).Columns.Count Then
            Set rng = Selection
            
            'Repeat for every cell in the first range
            For i = 1 To rng.Areas(1).Cells.Count
                'Assign cell value from range 1 to a temporary variable
                tmp = rng.Areas(1).Cells(i).Value
                'Assign cell value in range 1 to matching cell from range 2
                rng.Areas(1).Cells(i).Value = rng.Areas(2).Cells(i).Value
                'Assign matching cell in range 2 to value of temporary variable
                rng.Areas(2).Cells(i).Value = tmp
            Next i
        End If
    End If
End Sub


Also I believe that whenever a workbook containing a macro is open, it will work in all other open workbooks? Is that correct?


My method is to have one template file on my desktop with macros in it.

Then whenever I want to create a new file, I will just start from the template, and then, SaveAs : "Appropriate Name".

Does anyone have any better ideas for macro management!


Thanks so much!!!