Hier die Version mit Variable und ein Wunsch
31.12.2022 13:11:05
kurt
Hallo,
anbei:
'---- orginal von chris, mit meiner kleinen Änderung ----------------
Private Sub Rg_Vorlage_kopieren()
Dim wb As Workbook
Dim thiswb As Workbook
Dim b As Boolean
Dim i&, ze
Set thiswb = ThisWorkbook
i = ActiveCell.Row
For Each wb In Application.Workbooks
If wb.name Like "__Rechnungs-Programm Vers.*.xlsm" Then
b = True
Exit For
End If
Next wb
' Stop
If Not b Then
' MsgBox "nix gefunden"
Exit Sub
End If
'------- ab hier meine Änderung --------------------------------
wb.Activate
ze = ActiveSheet.name
'- somit wird der Tabellenname von der Empfängerdatei übernommen
'---- und zurück ------------------------------------------------------
thiswb.Activat
With ActiveSheet
wb.Worksheets(ze).Range("K12:K20") = Application.Transpose(.Range(.Cells(i, 2), .Cells(i, 10)))
End With
wb.Activate
Application.ScreenUpdating = True
End Sub
funktioniert einwandfrei.
Meine Frage, wie kann ich dieses Makro für Doppelklick auf Zelle einbinden ?
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Excel.Range, Cancel As Boolean)
Application.EnableEvents = True
If Not Intersect(Target, Range("B2:K65000")) Is Nothing Then
Cancel = True
ActiveSheet.Unprotect (getStrPasswort)
Range(Cells(Target.Row, 2), Cells(Target.Row, 10)).Select 'selektieren
ActiveSheet.Range("K12:K20") = Application.Transpose(Range(Cells(Target.Row, 2), Cells(Target.Row, 10)).Value)
End Sub
gruß kurt