Private Sub CommandButton1_Click()
Dim a As String
Dim b As Integer
Dim c As Integer
Dim d As String
Dim e As Integer
Dim f As Integer
Dim Index As Integer
a = Mid(TextBox1.Text, 1, 1)
b = Mid(TextBox1.Text, 2, 2)
c = Asc(a) - 64
d = Mid(TextBox2.Text, 1, 1)
e = Mid(TextBox2.Text, 2, 2)
f = Asc(d) - 64
With Range(Cells(b, c), (Cells(e, f)))
If Range(Cells(b, c), (Cells(e, f))).Value = "" Then
If Range(Cells(b, c), (Cells(e, f))).Rows.Count = 5 Or _
Range(Cells(b, c), (Cells(e, f))).Columns.Count = 5 Then
.Value = "#"
.Font.Bold = True
.Interior.Color = vbYellow
Else
MsgBox "Bitte Abstand von 5 Zeilen/Spalten wählen", vbOKOnly & vbInformation, " _
Hinweis"
Exit Sub
End If
Else
MsgBox "Diese Zelle ist bereits belegt", vbOKOnly & vbInformation, "Hinweis"
Exit Sub
End If
End With
Range(Cells(b, c), (Cells(e, f))).Select
For Index = xlEdgeLeft To xlEdgeRight
With Selection.Borders(Index)
.LineStyle = xlDouble
.Weight = xlThick
End With
Next Index
End Sub
Ich lese aus einer Userform dort eigegebene Zellen aus und wähle sie über diese Funktion dann an und fülle sie. Funktioniert soweit super.
if Application.CountA(Range(Cells(b, c), (Cells(e, f)))) = 0
With Range(Cells(b, c), (Cells(e, f)))
If WorksheetFunction.CountA(.Cells) = 0 Then
If .Rows.Count = 5 Or .Columns.Count = 5 Then
.Value = "#"
.Font.Bold = True
.Interior.Color = vbYellow
Else
MsgBox "Bitte Abstand von 5 Zeilen/Spalten wählen", _
vbOKOnly & vbInformation, " Hinweis """
Exit Sub
End If
Else
MsgBox "Diese Zellen sind bereits belegt", _
vbOKOnly & vbInformation, "Hinweis"
Exit Sub
End If
End With
With Range(Cells(b, c), (Cells(b+4, c+4)))
Private Sub CommandButton1_Click()
Dim a As String
Dim b As Integer
Dim c As Integer
Dim d As String
Dim e As Integer
Dim f As Integer
Dim Index As Integer
a = Mid(TextBox1.Text, 1, 1)
b = Mid(TextBox1.Text, 2, 2)
c = Asc(a) - 64
d = Mid(TextBox2.Text, 1, 1)
e = Mid(TextBox2.Text, 2, 2)
f = Asc(d) - 64
With Range(Cells(b, c), (Cells(e, f)))
If Range(Cells(b, c), (Cells(e, f))).Value = "" Then
If Range(Cells(b, c), (Cells(e, f))).Rows.Count = 5 Or _
Range(Cells(b, c), (Cells(e, f))).Columns.Count = 5 Then
.Value = "#"
.Font.Bold = True
.Interior.Color = vbYellow
Else
MsgBox "Bitte Abstand von 5 Zeilen/Spalten wählen", vbOKOnly & vbInformation, " _
Hinweis"
Exit Sub
End If
Else
MsgBox "Diese Zelle ist bereits belegt", vbOKOnly & vbInformation, "Hinweis"
Exit Sub
End If
End With
Range(Cells(b, c), (Cells(e, f))).Select
For Index = xlEdgeLeft To xlEdgeRight
With Selection.Borders(Index)
.LineStyle = xlDouble
.Weight = xlThick
End With
Next Index
End Sub
Ich lese aus einer Userform dort eigegebene Zellen aus und wähle sie über diese Funktion dann an und fülle sie. Funktioniert soweit super.
if Application.CountA(Range(Cells(b, c), (Cells(e, f)))) = 0
With Range(Cells(b, c), (Cells(e, f)))
If WorksheetFunction.CountA(.Cells) = 0 Then
If .Rows.Count = 5 Or .Columns.Count = 5 Then
.Value = "#"
.Font.Bold = True
.Interior.Color = vbYellow
Else
MsgBox "Bitte Abstand von 5 Zeilen/Spalten wählen", _
vbOKOnly & vbInformation, " Hinweis """
Exit Sub
End If
Else
MsgBox "Diese Zellen sind bereits belegt", _
vbOKOnly & vbInformation, "Hinweis"
Exit Sub
End If
End With
With Range(Cells(b, c), (Cells(b+4, c+4)))