Excel VBA

css navigation by Css3Menu.com

Using Ubound

Ubound and Lbound are cool statements to find out the upper and lower limits of an array.

For years, I did not use arrays because I did not understand them. Since so much of what I get called on to do is parsing text files, I place the parsing elements in arrays and only have one place to look for changes.

ChgOarRay = Array(5, 13, 26, 41)
ChgoCT = Array(7, 8, 13, 14)

Line Input #1, PayLine
            ItemLine = 21
            Do While Mid(PayLine, 10, 3) > "   "
                For S = 1 To UBound(ChgOarRay)	' How many items in array
                    Cells(ItemLine, S) = Mid(PayLine, ChgOarRay(S), ChgoCT(S))
                    If ItemLine = 22 Then
                        Range("N30") = Mid(PayLine, 117, 12)
                        Range("N38") = "=" & Cells(31, 14).Address
                    End If
      '              Debug.Print PayLine
                Next
                Line Input #1, PayLine
                ItemLine = ItemLine + 1
            Loop

I also learned a valuable lesson about Input while working on this assignment. Line Input #1, daRow inputs the entire line; whereas, Input 31, daRow truncates or line-feeds when it gets to commas (,).

© 2004-2024

Updated:  04/17/2024 12:26
This page added:  17 April 2004