Zunächst einmal tut mir leid, diese Frage hier zu posten. Diese Frage bezieht sich eher auf Mathematik, nicht auf Programmierung, aber ich kenne keinen anderen Ort, um Hilfe zu suchen. Grundsätzlich funktioniert mein Code, um die Markierung zu markieren, die durch den Benutzer unter Verwendung von Alphabet und Nummer, 1A, 1B, 1C, 1D usw. markiert ist. Es gibt 20 verschiedene Stile (1 mal 1 Etikett bis 20 mal 20 Etikett) zum Beschriften der ausgewählten Zellen. Das Problem tritt auf, wenn ich eine größere Zahl wie 5 für meine erste Auswahl wähle und die erste Auswahl bei 3A endet (die Beschriftung lautet wie folgt: Start: 1A 1B 1C 1D 1E 2A 2B 2C 2D 2E 3A, die nächste Auswahl 2 wählen als zweite Auswahl, die Beschriftung wird falsch wie folgt sein: 3B 3C 3D 3E bis 3Z und wird fortgesetzt, bis letzte Zellen als Nummer 8 nur, wo die richtige Kennzeichnung sollte wie folgt sein: 4A 4B 5A 5B 6A 6B.Ich weiß nicht einmal was .. mit dem Code falsch ist und somit brauche ich Hilfe von Ihnen Vielen Dank im Voraus Diese der Code ist und ich wähle Stil nur 1 bis 2 nur die einzige andere Sache im Code ist die Nummer:Etwas falsch mit Label mit Makro Excel
Public A, B As Integer
Sub AutoLabel()
'to label the cell in term of 1A and etc
A = 1
B = 1
End Sub
Sub LabelTest()
Dim Cell As Range
With Selection
' allign text so that it is centered between the top and bottom of the cell
.HorizontalAlignment = xlCenter
' allign text so that it is centered between the left and right of the cell
.VerticalAlignment = xlCenter
SR = .Row
SC = .Column
LR = SR + .Rows.Count - 1
LC = SC + .Columns.Count - 1
End With
' to input the first cell as 1A, and next cell as 1B and etc
For Each Cell In Selection
Cell.value = B & Mid("ABCDEFGHIJKLMNOPQRSTUVWXYZ", A, 1)
A = A + 1
If A = 2 Then A = 1: B = B + 1
Next Cell ' run next selected cell by user
End Sub
Sub LabelTest2()
Dim Cell As Range
With Selection
' allign text so that it is centered between the top and bottom of the cell
.HorizontalAlignment = xlCenter
' allign text so that it is centered between the left and right of the cell
.VerticalAlignment = xlCenter
SR = .Row
SC = .Column
LR = SR + .Rows.Count - 1
LC = SC + .Columns.Count - 1
End With
' to input the first cell as 1A, and next cell as 1B and etc
For Each Cell In Selection
Cell.value = B & Mid("ABCDEFGHIJKLMNOPQRSTUVWXYZ", A, 1)
A = A + 1
If A = 3 Then A = 1: B = B + 1
Next Cell ' run next selected cell by user
End Sub
I asked the same question here but no reply
Sie für die schnelle Hilfe danken. Kannst du mir aber sagen, wo ich die Funktion in die Codierung einbauen soll? – RainyDay
Oder besser, stellen Sie mir volle Codierung zur Verfügung, weil ich ein bisschen verwirrt bin, wie man Funktion benutzt. Vielen Dank. – RainyDay
Deklarieren Sie die Konstante und die Funktion außerhalb Ihres 'Sub'. Ich habe die Antwort mit einem Fragment aktualisiert, das besser veranschaulicht, wie man es nennen könnte. – jsheeran