kann mir bitte jemand helfen? Ich möchte diese zwei Makros mit nur einem Commandbutton auslösen. Geht das? Sind eben leider unterschiedle Ordner die durchsucht werden müssen und da meckert der Debugger bei Dim strDatei weil halt Mehrfachdeklarierung.
Danke René
Private Sub CommandButton1_Click()
Dim strDatei As String, lngZ As Long
Const VERZEICHNIS As String = "C:\Beanstandungen_2011\"
If Dir(VERZEICHNIS, vbDirectory) = "" Then
MsgBox VERZEICHNIS & " wurde nicht gefunden!" & Space(10), 64, "weise hin..."
Exit Sub
End If
With ActiveSheet
.Columns(1).ClearContents
strDatei = Dir(VERZEICHNIS & "*" & Cells(3, 3) & "*.xls", vbNormal)
If Dir(VERZEICHNIS & "*" & Cells(3, 3) & "*.xls", vbNormal) = "" Then
MsgBox ("Für diese Auswahl liegen keine erfassten Beanstandungen vor!")
End If
Do While strDatei ""
lngZ = lngZ + 2
.Hyperlinks.Add Anchor:=.Cells(lngZ, 1), _
Address:=VERZEICHNIS & strDatei, SubAddress:="", _
TextToDisplay:=strDatei
strDatei = Dir
Loop
End With
End Sub
Private Sub CommandButton2_Click()
Dim strDatei As String, lngZ As Long
Const VERZEICHNIS As String = "C:\Rückmeldungen\"
If Dir(VERZEICHNIS, vbDirectory) = "" Then
MsgBox VERZEICHNIS & " wurde nicht gefunden!" & Space(10), 64, "weise hin..."
Exit Sub
End If
With ActiveSheet
.Columns(5).ClearContents
strDatei = Dir(VERZEICHNIS & "*" & Cells(5, 3) & "*.xls", vbNormal)
If Dir(VERZEICHNIS & "*" & Cells(5, 3) & "*.xls", vbNormal) = "" Then
MsgBox ("Für diese Beanstandung liegen keine Rückmeldungen vor!")
End If
Do While strDatei ""
lngZ = lngZ + 2
.Hyperlinks.Add Anchor:=.Cells(lngZ, 5), _
Address:=VERZEICHNIS & strDatei, SubAddress:="", _
TextToDisplay:=strDatei
strDatei = Dir
Loop
End With
End Sub