Hi, I am trying to edit or make some old vba code work.
After copying a Range from one workbook and pasting them into another (and it works) that part of the vba code should check a column and if any cell contains a certain string or is empty, the row should be deleted.
With the empty cells the code are working and deleting the rows. With the strings not. But I dont even understand how it is working.
The variable for searching the strings is the
"KeinProfil =...."
Thats what is not working
With the line " this = UCase(Trim(Selection.Cells(1, 2).Value & Selection.Cells(1, 3).Value))" the code is finding correctly the empty cells. But thats what I dont understand.
The code runs till the end with no errors.
I've been trying to fix it but couldn't find the solution :/
After copying a Range from one workbook and pasting them into another (and it works) that part of the vba code should check a column and if any cell contains a certain string or is empty, the row should be deleted.
With the empty cells the code are working and deleting the rows. With the strings not. But I dont even understand how it is working.
The variable for searching the strings is the
"KeinProfil =...."
Thats what is not working
With the line " this = UCase(Trim(Selection.Cells(1, 2).Value & Selection.Cells(1, 3).Value))" the code is finding correctly the empty cells. But thats what I dont understand.
The code runs till the end with no errors.
I've been trying to fix it but couldn't find the solution :/
VBA Code:
last = UCase(Trim(Range("B6").Value & Range("C6").Value))
GewichtAnfang = "F6"
LaengeAnfang = "G6"
KeinProfil = "$Gesamtstückzahl$Länge FW-Abschnitt [m]$Nettogewicht FW$Neigung(ja=1):"
KeinProfil = KeinProfil & "$Endstirnplatten (0=gelenkig; 1=biegesteif):$Länge FW-Träger [m]"
KeinProfil = KeinProfil & "$Beanspruchungsgruppe$Eingabe: ja/nein$Satteldach$auslegen+messen"
KeinProfil = KeinProfil & "$nur Montageaufwand, kein Materialpreis$HM28x15, l=100mm$22x175"
KeinProfil = KeinProfil & "$Materialdicke/Umfang$Fl35x25$%"
KeinProfil = KeinProfil & "$"
For i = 6 To 5000
iRow = i & ":" & i
Rows(iRow).Select
this = UCase(Trim(Selection.Cells(1, 2).Value & Selection.Cells(1, 3).Value))
If InStr(KeinProfil, "$" & this & "$") > 0 Then
Rows(iRow).Delete
last = this
i = i - 1
Else
If this = "" Then
Call Zwischensumme(i, GewichtAnfang, LaengeAnfang)
'If MsgBox("Jetzt wird gelöscht", vbOKCancel) = vbCancel Then Stop
Loeschbereich = i & ":5000"
Rows(Loeschbereich).Delete
i = 5000
Else
If this <> last Then
Call Zwischensumme(i, GewichtAnfang, LaengeAnfang)
GewichtAnfang = "F" & i
LaengeAnfang = "G" & i
'If MsgBox(last, vbOKCancel) = vbCancel Then Stop
End If
last = this
End If
End If
Next