Malcolm torishi
Board Regular
- Joined
- Apr 26, 2013
- Messages
- 219
I have the following code, in my worksheet known as “Out”, and what this code does is ever time I double click on a cell under column AB it Clears the Contents from that row, 25 cells to the left of column AB and the first 3 cells to the right of column AO on the same row. plus it paste the 1st cell value, which is my column C, into my worksheet known as “In”. So basically it’s moving names from sheet Out to sheet In.
Now what I would like the following code to do is every time I double click on a cell under column AB which then Clears the Contents from on that row, 25 cells to the left etc, I then want the code to drop a “-“ sign in to my 1st cell, which is my column C, on the row that’s been double click. Can this be done by adding an If Else type statement into the code?
If anyone can help it would be appreciated, thank you
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
'Modified 6/18/2019 3:09 PM EDT
If Target.Column = 28 And Target.Row > 1 Then
Cancel = True
Dim Lastrow As Long
Lastrow = Sheets(3).Cells(Rows.Count, "A").End(xlUp).Row + 1
Target.Offset(, -25).Resize(, 1).Copy Sheets(3).Cells(Lastrow, 1)
Target.Offset(, -25).Resize(, 25).SpecialCells(xlCellTypeConstants).ClearContents
Range("AO" & Target.Row).Resize(, 3).ClearContents
End If
End Sub
Now what I would like the following code to do is every time I double click on a cell under column AB which then Clears the Contents from on that row, 25 cells to the left etc, I then want the code to drop a “-“ sign in to my 1st cell, which is my column C, on the row that’s been double click. Can this be done by adding an If Else type statement into the code?
If anyone can help it would be appreciated, thank you
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
'Modified 6/18/2019 3:09 PM EDT
If Target.Column = 28 And Target.Row > 1 Then
Cancel = True
Dim Lastrow As Long
Lastrow = Sheets(3).Cells(Rows.Count, "A").End(xlUp).Row + 1
Target.Offset(, -25).Resize(, 1).Copy Sheets(3).Cells(Lastrow, 1)
Target.Offset(, -25).Resize(, 25).SpecialCells(xlCellTypeConstants).ClearContents
Range("AO" & Target.Row).Resize(, 3).ClearContents
End If
End Sub