In untenstehenden Code werden verschiedene Bereiche geprüft ob sie leer sind oder nicht. Sind alle Bereiche ausgefüllt, soll die datei als
c:\temp\RfC_Form_"Benutzer".xls abgelegt werden. Fuktioniert aber nicht so wie gedacht.
Danke und Gruss
Maruseru
Private Sub CommandButton3_Click()
Dim rngPflicht As Range, rngBereich As Range
Dim intLeere As Integer
Set rngPflicht = [D5,D10,D15,D20,D25,D30,D35,D40,G4]
For Each rngBereich In rngPflicht.Areas
intLeere = intLeere + Application.WorksheetFunction.CountBlank(rngBereich)
Next
If intLeere > 0 Then
MsgBox "You have not filled in all mandatory green fields for the calculation! ", _
vbInformation, "INFORMATION"
Else
On Error Resume Next 'If save has beeen canceled
If ActiveWorkbook.Saved Then
ActiveWorkbook.Save
Else
'user = Application.UserName
user = Environ("Username")
Path = "c:\temp"
ActiveWorkbook.SaveAs Filename = Path & "\RfC Form_" & user & ".xls", FileFormat:= _
xlNormal
MsgBox "The data have been saved temporary as c:\temp\RfC Form_" & user & ".xls" & _
_
vbCrLf & vbCrLf & "To continued click on the Button Main Menu!", vbInformation, "INFORMATION"
End If
End If
Application.ScreenUpdating = True
End Sub