Von |
AndreasRoe |
eMail |
|
Am |
03. September 2008 um 12:27:43 |
Frage |
Hallo.
Quellcode von VBA/Excel2003:
+++++++++++++++++++++++++++++++++++++++++++++++++++++++Option Explicit Sub Fehlt_Datum() Dim aTage(1 To 5) As Date Dim iKW As Long Dim iAnzTage As Long Dim dMontag As Date Dim dFreitag2 As Date Dim iIndex As Long Dim rZelle As Range Dim bWert As Boolean Dim Datum1 Datum1 = Date With Worksheets("Datum") iKW = DatePart("ww", Application.Range("B12").Value, vbMonday, vbFirstFourDays) iAnzTage = 7 * iKW dMontag = Datum1 'MsgBox " Es existiert, also weiter gehts " dFreitag2 = dMontag - 5 'MsgBox " Der 29.08.2008 fehlt " 'dFreitag2 = dMontag - 5 If Weekday(Date) = 4 Then For iIndex = 1 To 5 aTage(iIndex) = dFreitag2 Next iIndex End If bWert = True For iIndex = 1 To 1 Set rZelle = .Range("B12:B" & iAnzTage).Find(aTage(iIndex), LookIn:=xlValues, Lookat:=xlWhole) If rZelle Is Nothing Then MsgBox "der " & Format(aTage(iIndex), "dd.mm.yyyy") & " fehlt.", _ 48, " Hinweis für " & Application.UserName bWert = False End If Next iIndex If bWert = True Then MsgBox " Es existiert, also weiter gehts " 'hier soll dann mit Call ein weiteres Makro aufgerufen werden End If End With Exit Sub End Sub +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Füge ich den Quellcode aber in ein Modul in Visual-Basic-6 ein, funktioniert es nicht mehr wie gewünscht. Obwohl das Datum 29.08.2008 in drei Zellen existiert kommt die MsgBox: "der 29.08.2008 fehlt". Es sollte dann aber die MsgBox " Es existiert, also weiter gehts " erscheinen.
Kann mir jemand helfen?
beste Grüße, Andreas
PS: Was mir auffällt ist, das die Variable rZelle (bei Set rZelle...) keinen Wert in VB6 bekommt, in VBA-Modul schon.
Ich habe mal eine Excel.zip Datei hochgeladen:
http://www.file-upload.net/download-1086423/Datum.zip.html
Das ist das funktionierende Beispiel mit VBA.
|
|