Thema Datum  Von Nutzer Rating
Antwort
09.03.2016 21:19:14 deba147
Solved
11.03.2016 07:18:38 Gast91261
NotSolved
11.03.2016 11:20:17 deba147
NotSolved
Blau bestimmten Wert in anderem Tabellenblatt suchen und Folgeaktionen
11.03.2016 23:26:35 Gast65146
NotSolved
13.03.2016 19:07:47 deba147
NotSolved
13.03.2016 23:40:52 Gast72569
NotSolved
14.03.2016 09:51:23 deba147
NotSolved

Ansicht des Beitrags:
Von:
Gast65146
Datum:
11.03.2016 23:26:35
Views:
756
Rating: Antwort:
  Ja
Thema:
bestimmten Wert in anderem Tabellenblatt suchen und Folgeaktionen

Hallo,

ok, hier mal eine Kompaktlösung mit einer Msgbox, für solche zusätzlichen Buttonbeschriftungen und weitere Anpassungen mußt Dir dann aber das Erstellen einer Userform aneignen, das ist sinnvoller und einfacher...

' **********************************************************************
' Modul: DieseArbeitsmappe  Typ: Klassenmodul der Arbeitsmappe
' **********************************************************************

Option Explicit

Private Sub Workbook_Open()
With Tabelle1
    Call .Activate
    Call .Cells(8, 4).Select '// D8
End With
End Sub
' **********************************************************************
' Modul: Tabelle1  Typ: Klassenmodul des Tabellenblattes
' **********************************************************************

Option Explicit

Private Sub Worksheet_Activate()
Call Cells(8, 4).Select
End Sub

Private Sub Worksheet_Change(ByVal Target As Range)
With Target
    If .Address = "$D$8" Then _
      If .Value <> vbNullString Then _
          Call prcResetDate(probjTarget:=Target)
End With
End Sub

Private Sub prcResetDate(ByRef probjTarget As Range)
Dim objCell As Range
Set objCell = Tabelle2.Columns(2).Find(What:=probjTarget.Value, _
   LookIn:=xlValues, LookAt:=xlWhole, MatchCase:=False)
If Not objCell Is Nothing Then
  With objCell
      Call .Parent.Activate
      Call .Select
      Select Case fncMsgBoxCustom("Der Wert " & .Value & " wurde gefunden," & _
            " möchten Sie das Datum in Spalte D ersetzen?", _
            vbExclamation + vbYesNoCancel, "Wert gefunden!")
         Case Is = vbYes
             .Offset(0, 2).Value = Date
             Call prcActivateSheet(prwksSheet:=Me)
         Case Is = vbNo
             Call prcActivateSheet(prwksSheet:=Me)
      End Select
  End With
  Set objCell = Nothing
End If
End Sub

Private Sub prcActivateSheet(ByRef prwksSheet As Worksheet)
  With prwksSheet
      Call .Cells(8, 4).ClearContents
      Call .Activate
  End With
End Sub
' **********************************************************************
' Modul: Modul1  Typ: Standardmodul
' **********************************************************************

Option Explicit
Option Private Module

Private Declare Function GetCurrentThreadId Lib "kernel32.dll" () As Long
Private Declare Function SetDlgItemText Lib "user32.dll" Alias "SetDlgItemTextA" ( _
   ByVal hDlg As Long, _
   ByVal nIDDlgItem As Long, _
   ByVal lpString As String) As Long
Private Declare Function SetWindowsHookEx Lib "user32.dll" Alias "SetWindowsHookExA" ( _
   ByVal idHook As Long, _
   ByVal lpfn As Long, _
   ByVal hmod As Long, _
   ByVal dwThreadId As Long) As Long
Private Declare Function UnhookWindowsHookEx Lib "user32.dll" ( _
   ByVal hHook As Long) As Long
 
Private Const WH_CBT As Long = 5
Private Const HCBT_ACTIVATE As Long = 5
Private Const IDCANCEL As Long = 2

Private llngHhook As Long

Public Function fncMsgBoxCustom(ByVal pvstrMsgText As String, _
  ByVal pvenmButtons As VbMsgBoxStyle, ByVal pvstrBoxTitle As String) As VbMsgBoxResult
    llngHhook = SetWindowsHookEx(WH_CBT, _
        AddressOf WndHookProc, 0&, GetCurrentThreadId)
   fncMsgBoxCustom = MsgBox(pvstrMsgText, pvenmButtons, pvstrBoxTitle)
End Function

Private Function WndHookProc(ByVal pvlnguMsg As Long, _
    ByVal pvlngwParam As Long, ByVal pvlnglParam As Long) As Long
    If pvlnguMsg = HCBT_ACTIVATE Then
        Call SetDlgItemText(pvlngwParam, IDCANCEL, "Gerät bearbeiten")
        Call UnhookWindowsHookEx(llngHhook)
    End If
    WndHookProc = False
End Function

Gruß,


Ihre Antwort
  • Bitte beschreiben Sie Ihr Problem möglichst ausführlich. (Wichtige Info z.B.: Office Version, Betriebssystem, Wo genau kommen Sie nicht weiter)
  • Bitte helfen Sie ebenfalls wenn Ihnen geholfen werden konnte und markieren Sie Ihre Anfrage als erledigt (Klick auf Häckchen)
  • Bei Crossposting, entsprechende Links auf andere Forenbeiträge beifügen / nachtragen
  • Codeschnipsel am besten über den Code-Button im Text-Editor einfügen
  • Die Angabe der Emailadresse ist freiwillig und wird nur verwendet, um Sie bei Antworten auf Ihren Beitrag zu benachrichtigen
Thema: Name: Email:



  • Bitte beschreiben Sie Ihr Problem möglichst ausführlich. (Wichtige Info z.B.: Office Version, Betriebssystem, Wo genau kommen Sie nicht weiter)
  • Bitte helfen Sie ebenfalls wenn Ihnen geholfen werden konnte und markieren Sie Ihre Anfrage als erledigt (Klick auf Häckchen)
  • Bei Crossposting, entsprechende Links auf andere Forenbeiträge beifügen / nachtragen
  • Codeschnipsel am besten über den Code-Button im Text-Editor einfügen
  • Die Angabe der Emailadresse ist freiwillig und wird nur verwendet, um Sie bei Antworten auf Ihren Beitrag zu benachrichtigen

Thema Datum  Von Nutzer Rating
Antwort
09.03.2016 21:19:14 deba147
Solved
11.03.2016 07:18:38 Gast91261
NotSolved
11.03.2016 11:20:17 deba147
NotSolved
Blau bestimmten Wert in anderem Tabellenblatt suchen und Folgeaktionen
11.03.2016 23:26:35 Gast65146
NotSolved
13.03.2016 19:07:47 deba147
NotSolved
13.03.2016 23:40:52 Gast72569
NotSolved
14.03.2016 09:51:23 deba147
NotSolved