Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean) If Target.Column = 4 Then Cancel = True With Sheets(14) Lr = .Cells(Rows.Count, 1).End(xlUp).Row + 1 .Cells(Lr, 1).Value = Target.Value End With ElseIf Target.Row = 244 Then Cancel = True With Sheets(14) Lr = .Cells(Rows.Count, 4).End(xlUp).Row + 1 .Cells(Lr, 4).Value = Target.Value End With End If End Sub
[/vba]
Интересует [vba]
Код
ElseIf Target.Row = 244 Then
[/vba] После двойного нажатия ячейка 244 должна скопироваться и вставится в 4-й столб, но вставляется во 2-й, в чём может быть косяк?
Подскажите что не так с кодом?
[vba]
Код
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean) If Target.Column = 4 Then Cancel = True With Sheets(14) Lr = .Cells(Rows.Count, 1).End(xlUp).Row + 1 .Cells(Lr, 1).Value = Target.Value End With ElseIf Target.Row = 244 Then Cancel = True With Sheets(14) Lr = .Cells(Rows.Count, 4).End(xlUp).Row + 1 .Cells(Lr, 4).Value = Target.Value End With End If End Sub
[/vba]
Интересует [vba]
Код
ElseIf Target.Row = 244 Then
[/vba] После двойного нажатия ячейка 244 должна скопироваться и вставится в 4-й столб, но вставляется во 2-й, в чём может быть косяк?Dmitry1992_92
Сообщение отредактировал Dmitry1992_92 - Пятница, 09.02.2018, 12:21
Всё разобрался, нужно было написать If а не ElseIf
[vba]
Код
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean) If Target.Column = 4 Then Cancel = True With Sheets(14) Lr = .Cells(Rows.Count, 1).End(xlUp).Row + 1 .Cells(Lr, 1).Value = Target.Value End With End If If Target.Row = 244 Then Cancel = True With Sheets(14) Lr = .Cells(Rows.Count, 3).End(xlUp).Row + 1 .Cells(Lr, 3).Value = Target.Value End With End If End Sub
[/vba]
Всё разобрался, нужно было написать If а не ElseIf
[vba]
Код
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean) If Target.Column = 4 Then Cancel = True With Sheets(14) Lr = .Cells(Rows.Count, 1).End(xlUp).Row + 1 .Cells(Lr, 1).Value = Target.Value End With End If If Target.Row = 244 Then Cancel = True With Sheets(14) Lr = .Cells(Rows.Count, 3).End(xlUp).Row + 1 .Cells(Lr, 3).Value = Target.Value End With End If End Sub