خرید بک لینک

Vote count: 0

I am a CAD engineer with a relativly small knowledge of VBA. But today I decided to modify a 5 year old programm and came across this problem:

I have a combobox which can display items from 2 different sheets, depends on which one of two radio boxes is selected. This works with Cases. Honestly I have no idea how cases really work, so I dont know how the combobox knows which case to take, but it works so I'm not changing it.

Now currently the code is like this:

which means if I add a new row into the table I have to copy those case select things

    Private Sub ComboBox5_Change() 'Auswahl Rohr

Select Case ComboBox5.Value


    Case Tabelle6.Cells(4, 3) 'Welle in Rohr

        LängRo = Tabelle6.Cells(4, 6)
        OnCenRo = Tabelle6.Cells(4, 7)
        OffCeRo = Tabelle6.Cells(4, 8)
        MinRRo = Tabelle6.Cells(4, 9)



   Case Tabelle13.Cells(4, 3) 'ROHR IN ROHR

        LängRo = Tabelle13.Cells(4, 6)
        OnCenRo = Tabelle13.Cells(4, 7)
        OffCeRo = Tabelle13.Cells(4, 8)
        MinRRo = Tabelle13.Cells(4, 9)

   Case Tabelle13.Cells(5, 3) 'ROHR IN ROHR

        LängRo = Tabelle13.Cells(5, 6)
        OnCenRo = Tabelle13.Cells(5, 7)
        OffCeRo = Tabelle13.Cells(5, 8)
        MinRRo = Tabelle13.Cells(5, 9)

End Select

End Sub

I tried to fix this with something like this:

Private Sub ComboBox5_Change() 'Auswahl Rohr

Dim for1 As Long
Dim for2 As Long
For for2 = 3 To 7
If Tabelle6.Cells(for2, 3) = "" Then
GoTo fert
Else
Select Case ComboBox5.Value
    Case Tabelle6.Cells(for2, 3) 'Welle in Rohr

        LängRo = Tabelle6.Cells(for2, 6)
        OnCenRo = Tabelle6.Cells(for2, 7)
        OffCeRo = Tabelle6.Cells(for2, 8)
        MinRRo = Tabelle6.Cells(for2, 9)
End Select
End If
Next


For for1 = 3 To 7
If Tabelle10.Cells(for1, 3) = "" Then
GoTo fert
Else
Select Case ComboBox5.Value
    Case Tabelle10.Cells(for1, 3) 'ROHR IN ROHR

        LängWe = Tabelle10.Cells(for1, 6)
        OnCenWe = Tabelle10.Cells(for1, 7)
        OffCeWe = Tabelle10.Cells(for1, 8)
        MinRWe = Tabelle10.Cells(for1, 9)

End Select
  End If
  Next

fert:

End Sub

But now I get an overflow error when I press a button that uses var LängRO

and I don't really know why

asked 1 min ago

برچسب: نویسنده: استخدام کار تاريخ: چهارشنبه 30 تير 1395 ساعت: 7:51

صفحه بندی