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.

Excel VBA

Empfohlene Antworten

Veröffentlicht

Hallo,

nene will was in Excel programmieren, aber ehrlich gesagt kenne ich mich mit VBA gar nicht so recht aus, habe mehr C# gemacht. Naja also gibt es eine Formel in VBA die eine gesamte Spalte nimmt und diese nach Zahlen sortiert und diese zusammen führt in einem array? Also zb.

Spalte A Zahlen von 1-5 die mehrmals vorkommen, die gleichen Zahlen wie zb. die Zahl 2 kommt 5mal vor, diese wird dann in einer Variablen geschrieben oder mit den gesamten Zahlen in einem Array.

Schwer auszudrücken, was ich meine.....

hier mal n psyeudo code (so wies ich verstanden hab)

a = array[anzahl werte in spalte]

boolen vorhanden = false

int i = 0

int j = 0

int x = 0


for (i = 0 to anzahl werte in spalte){

   for (j = 0 to anzahl werte in array){

      if (wert in spalte[i] = array[j]){

         vorhanden = true

      }

      j = j + 1

   }

   j = 0

   if (vorhanden = false){

      array[x] = wert in spalte[i]

      x = x + 1

   }

   vorhanden = false

   i = i + 1

}


int n = laenge von array


for (int y = n - 1; y > 0; y--){

   for (int z = 0; z < y; z++){

      if (array[z] > array[z + 1]){ 

         int swp = array[z]

         array[z] = array[z + 1]

         array[z + 1] = swp

      } 

   } 

}

  • 6 Monate später...

Hallo,

in VBA würde das von der Syntax her so aussehen:


Sub Test()

    Dim a()                   As String

    Dim vorhanden             As Boolean

    Dim i                     As Integer

    Dim j                     As Integer

    Dim x                     As Integer

    Dim maxZeile              As Long

    Dim n                     As Integer

    Dim y                     As Integer

    Dim z                     As Integer

    Dim swp                   As String


    i = 0

    j = 0

    x = 0


    vorhanden = False


    'Letzte Zeile suchen

    maxZeile = 1

    Do

        maxZeile = maxZeile + 1

    Loop Until Cells(maxZeile, 1).Value = ""




    For i = 0 To maxZeile

        For j = 0 To UBound(a)

            If Cells(i, 1) = a(j) Then

                vorhanden = True

            End If

            j = j + 1

        Next i


        j = 0

        If vorhanden = False Then

            a(x) = Cells(i, 1)

            x = x + 1

        End If

        vorhanden = False

        i = i + 1

    Next i


    n = LBound(a)


    For y = 1 To n Step -1

        For z = 0 To y - 1

            If a(z) > a(z + 1) Then

                swp = a(z)

                a(z) = a(z + 1)

                a(z + 1) = swp

            End If

        Next z

    Next y


End Sub

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.