Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

If in For each

Empfohlene Antworten

Veröffentlicht

Hallo Zusammen

ich bin neu hier, bin gerade dabei ein Ergebniskatalog zu kreieren in Excel.

Ich habe verschiedene Spalten in welcher verschiedene Checkboxen sind. Ich möchte mittels Button auslesen welche Checkbox ausgewählt ist und diese in ein anderes Datenblatt einfüllen (nur die Aktiven). Im Ergebnisdatenblatt (2tes) werden die Daten als Hyperlink ausgegeben, da ich verschiedene Templates hinterlegen will.

Nun dieses Teil hab ich schon, nun wenn ich allerdings in einer Spalte kein Checkbox ausgewählt habe, erscheint der Fehler "For kann nicht initialisiert werden"... kann mir jemand sagen, wo genau in meinem Text ich meine IF Anweisung einfüllen muss?

Danke und liebe Grüsse

Private Sub CommandButton1_Click()

valuesColumn1 = getArray(11, 20, 1)

valuesColumn2 = getArray(11, 14, 2)

valuesColumn3 = getArray(11, 14, 3)

valuesColumn4 = getArray(11, 20, 4)

valuesColumn5 = getArray(11, 17, 5)

valuesColumn6 = getArray(11, 14, 6)

Set objExcel = CreateObject("Excel.Application")

objExcel.Visible = True

objExcel.Workbooks.Open (ActiveWorkbook.Path & "\ergebnis-output.xls")

' ---- erste Spalte ----

i = 28 ' Startzeile

For Each entrie In valuesColumn1

Select Case entrie

Case "chk111"

Call setHyperlink(objExcel, "Auswahl", "B" & i, "\\xxxx.dot", "Projektplan")

Case "chk112"

Call setHyperlink(objExcel, "Auswahl", "B" & i, "hallo", "Ressourcenplan")

Case "chk113"

Call setHyperlink(objExcel, "Auswahl", "B" & i, "hallo", "Pendenzenliste")

Case "chk114"

Call setHyperlink(objExcel, "Auswahl", "B" & i, "hallo", "Terminplan")

Case "chk115"

Call setHyperlink(objExcel, "Auswahl", "B" & i, "hallo", "Meilensteine")

Case "chk116"

Call setHyperlink(objExcel, "Auswahl", "B" & i, "\xx")

Case "chk117"

Call setHyperlink(objExcel, "Auswahl", "B" & i, "hallo", "Ergebniskatalog")

Case "chk118"

Call setHyperlink(objExcel, "Auswahl", "B" & i, "hallo", "Systemanforderungen")

Case "chk119"

Call setHyperlink(objExcel, "Auswahl", "B" & i, "xx_Projekte\Vorlagen_Template\Ergebniskatalog\Projektauftrag.dot", "Projektauftrag")

Case "chk120"

Call setHyperlink(objExcel, "Auswahl", "B" & i, "\\xx_Projekte\Vorlagen_Template\Ergebniskatalog\Projektantrag.dot", "Projektantrag")

Case Else

Call setHyperlink(objExcel, "Auswahl", "B" & i, "", "")

End Select

i = i + 1

Next

' --- zweite Spalte

i = 28

For Each entrie In valuesColumn2

Select Case entrie

Case "chk211"

Call setHyperlink(objExcel, "Auswahl", "E" & i, "\\xx_Projekte\Vorlagen_Template\Ergebniskatalog\Situationsanalyse.dot", "Situationsanalyse")

Case "chk212"

Call setHyperlink(objExcel, "Auswahl", "E" & i, "\\xx_Projekte\Vorlagen_Template\Ergebniskatalog\Risikokatalog.dot", "Risikokatalog")

Case "chk213"

Call setHyperlink(objExcel, "Auswahl", "E" & i, "hallo", "Bedarfsanforderung")

Case "chk214"

Call setHyperlink(objExcel, "Auswahl", "E" & i, "hallo", "Projektvereinbarung")

Case Else

Call setHyperlink(objExcel, "Auswahl", "E" & i, "hallo", "hallo")

End Select

i = i + 1

Next

' --- dritte Spalte

i = 28

For Each entrie In valuesColumn3

Select Case entrie

Case "chk311"

Call setHyperlink(objExcel, "Auswahl", "I" & i, "hallo", "Ausschreibungstext")

Case "chk312"

Call setHyperlink(objExcel, "Auswahl", "I" & i, "hallo", "Kriterienkatalog")

Case "chk313"

Call setHyperlink(objExcel, "Auswahl", "I" & i, "hallo", "Evaluationsbericht")

Case "chk314"

Call setHyperlink(objExcel, "Auswahl", "I" & i, "hallo", "Offerte / Offert Auftrag")

Case Else

Call setHyperlink(objExcel, "Auswahl", "I" & i, "hallo", "hallo")

End Select

i = i + 1

Next

' --- vierte Spalte

i = 28

For Each entrie In valuesColumn4

Select Case entrie

Case "chk411"

Call setHyperlink(objExcel, "Auswahl", "L" & i, "\\xxxx.intra.admin.ch\BP\7_BPTK\715_Projekte\Vorlagen_Template\Ergebniskatalog\Einführungskonzept.dot", "Einführungskonzept")

Case "chk412"

Call setHyperlink(objExcel, "Auswahl", "L" & i, "hallo", "Nachofferte")

Case "chk413"

Call setHyperlink(objExcel, "Auswahl", "L" & i, "\\xxxx_Projekte\Vorlagen_Template\Ergebniskatalog\Migrationskonzept.dot", "Migrationskonzept")

Case "chk414"

Call setHyperlink(objExcel, "Auswahl", "L" & i, "hallo", "Installationsanweisung")

Case "chk415"

Call setHyperlink(objExcel, "Auswahl", "L" & i, "hallo", "Testkonzept")

Case "chk416"

Call setHyperlink(objExcel, "Auswahl", "L" & i, "\\xxxx"Systemarchitektur")

Case "chk417"

Call setHyperlink(objExcel, "Auswahl", "L" & i, "hallo", "Lösungsbeschreibung")

Case "chk418"

Call setHyperlink(objExcel, "Auswahl", "L" & i, "hallo", "Engineering-Manual")

Case "chk419"

Call setHyperlink(objExcel, "Auswahl", "L" & i, "hallo", "Betriebsanforderung")

Case "chk420"

Call setHyperlink(objExcel, "Auswahl", "L" & i, "\\xxxxx_Projekte\Vorlagen_Template\Ergebniskatalog\Changeplan.dot", "Changeplan")

Case Else

Call setHyperlink(objExcel, "Auswahl", "L" & i, "hallo", "hallo")

End Select

i = i + 1

Next

' --- fünfte Spalte

i = 28

For Each entrie In valuesColumn5

Select Case entrie

Case "chk511"

Call setHyperlink(objExcel, "Auswahl", "P" & i, "hallo", "Produktflyer")

Case "chk512"

Call setHyperlink(objExcel, "Auswahl", "P" & i, "hallo", "Schulungsunterlagen")

Case "chk513"

Call setHyperlink(objExcel, "Auswahl", "P" & i, "\\xxxx_Projekte\Vorlagen_Template\Ergebniskatalog\Ausbildungskonzept.dot", "Ausbildungskonzept")

Case "chk514"

xxxxx_Projekte\Vorlagen_Template\Ergebniskatalog\Betriebshandbuch.dot", "Betriebshandbuch")

Case "chk515"

Call setHyperlink(objExcel, "Auswahl", "P" & i, "hallo", "Betriebskonzept")

Case "chk516"

Call setHyperlink(objExcel, "Auswahl", "P" & i, "\\sxxxxxch\BP\7_BPTK\715_Projekte\Vorlagen_Template\Ergebniskatalog\Testbericht.dot", "Testbericht")

Case "chk517"

Call setHyperlink(objExcel, "Auswahl", "P" & i, "hallo", "Netzänderung")

Case Else

Call setHyperlink(objExcel, "Auswahl", "P" & i, "hallo", "hallo")

End Select

i = i + 1

Next

' --- sechste Spalte

i = 28

For Each entrie In valuesColumn6

Select Case entrie

Case "chk611"

Call setHyperlink(objExcel, "Auswahl", "S" & i, "hallo", "Abnahmeprotokoll")

Case "chk612"

Call setHyperlink(objExcel, "Auswahl", "S" & i, "hallo", "ISDS Konzept")

Case "chk613"

Call setHyperlink(objExcel, "Auswahl", "S" & i, "hallo", "SLA")

Case "chk614"

Call setHyperlink(objExcel, "Auswahl", "S" & i, "\\xxxxx", "Organisationshandbuch")

Case Else

Call setHyperlink(objExcel, "Auswahl", "S" & i, "hallo", "hallo")

End Select

i = i + 1

Next

End Sub

Sub setHyperlink(objExcel, myWorkBook, myRange, myAddress, mySubAddress)

With objExcel

.worksheets(myWorkBook).Activate

.range(myRange).Select

.ActiveSheet.Hyperlinks.Add Anchor:=.Selection, Address:=myAddress, TextToDisplay:=mySubAddress

End With

End Sub

Function getArray(startValue, endValue, columnValue)

Dim selectedChk() As String

j = 0

For i = startValue To endValue

If ActiveSheet.OLEObjects("chk" & columnValue & i).Object.Value = True Then

ReDim Preserve selectedChk(j)

selectedChk(j) = "chk" & columnValue & i

j = j + 1

End If

Next

getArray = selectedChk()

End Function

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.