Here’s a couple of options to consider. Both are worksheet event modules – to add them, right-click on the Tab name of the “Notice” sheet, select View Code, then copy the code to the window that appears on the right of the screen. Save the file & test.
The first is a Worksheet_BeforeDoubleClick. It is aimed at the F column (F2:F750 to be exact). Whenever you double click on any cell in that range, the value in that cell is copied to the next available empty cell in column A on the “Board” sheet. I’ve left an option in there (uncomment the line to activate) to convert the value in the cell to “OK” as well to signify that it’s been copied across. One macro, and no buttons required at all.
VBA Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
On Error GoTo Escape
Application.EnableEvents = False
If Not Intersect(Range("F2:F750"), Target) Is Nothing Then
Cancel = True
With Target.Cells
.Copy
Worksheets("Board").Cells(Rows.Count, "A").End(xlUp).Offset(1).PasteSpecial xlPasteValues
Application.CutCopyMode = False
'UNCOMMENT THIS NEXT LINE if you want the cell value in column F change to "OK" automatically
'.Value2 = "OK"
End With
End If
Continue:
Application.EnableEvents = True
Exit Sub
Escape:
MsgBox "Error " & Err.Number & ": " & Err.Description
Resume Continue
End Sub
The second is a Worksheet_SelectionChange. This one is aimed at column H (if you’re still wedded to having something there to “press”). Instead of hundreds of buttons though, simply add some text/formatting to the cells for effect (see below). Whenever a cell is selected, the value in column F of that row is copied to the next available empty cell in column A on the “Board” sheet. I’ve left an option in there (uncomment the line to activate) to convert the value in the cell to “OK” as well to signify that it’s been copied across. One macro, and no buttons required at all.
VBA Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
On Error GoTo Escape
Application.EnableEvents = False
If Target.Cells.CountLarge = 1 And Not Intersect(Range("H2:H750"), Target) Is Nothing Then
With Target.Cells.Offset(, -2)
.Copy
Worksheets("Board").Cells(Rows.Count, "A").End(xlUp).Offset(1).PasteSpecial xlPasteValues
Application.CutCopyMode = False
'UNCOMMENT THIS NEXT LINE if you want the cell value in column F change to "OK" automatically
'.Value2 = "OK"
End With
End If
Continue:
Application.EnableEvents = True
Exit Sub
Escape:
MsgBox "Error " & Err.Number & ": " & Err.Description
Resume Continue
End Sub
dwool40.xlsm |
---|
|
---|
| F | G | H |
---|
2 | OK | | ADD |
---|
3 | OK | | ADD |
---|
4 | 7308-11S | | ADD |
---|
5 | 7309-10H | | ADD |
---|
6 | 7308-11S | | ADD |
---|
7 | OK | | ADD |
---|
8 | OK | | ADD |
---|
|
---|