Eigenes Kontextmenü
19.09.2006 07:09:13
Josef
Ich habe in den Faq's folgenden Code gefunden:
Private Sub Worksheet_BeforeDoubleClick( _
ByVal Target As Excel.Range, Cancel As Boolean)
Dim oBar As CommandBar
Dim oBtn As CommandBarButton
Dim wks As Worksheet
Dim iCol As Integer
Cancel = True
Set wks = Worksheets("Daten")
Call DeleteCmdBar
Set oBar = Application.CommandBars.Add( _
Name:="StringInsert", _
Position:=msoBarPopup, _
MenuBar:=False, _
temporary:=True)
iCol = 1
Do Until IsEmpty(wks.Cells(1, iCol))
Set oBtn = oBar.Controls.Add
With oBtn
.Caption = wks.Cells(1, iCol).Value
.Style = msoButtonCaption
.OnAction = "GetValue"
End With
iCol = iCol + 1
Loop
CommandBars("StringInsert").ShowPopup
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Call DeleteCmdBar
End Sub
Sub GetValue()
ActiveCell.Value = _
Application.CommandBars("StringInsert") _
.Controls(Application.Caller(1)).Caption
End Sub
Hier werden im Kontextmenü nach einem Doppelklick in der Tabelle1 die Daten der Tabelle2 aus der Zeile A1 angezeigt.
Wo müßte man bitte hier im Code eine Änderung vornehmen, so das die Daten in der Tabele2 nicht aus der Zeile sondern aus der Spalte A herangezogen werden?
Danke
Josef