I created a macro that gets a list of elements (strings), puts them into an array, then creates an appropriate number of worksheets each named after an element in the array. Everything works fine. However, occationally when dealing with this list of elements, they are arranged in a sort of list-sublist-evenmoresublist pattern, meaning that there is some variable number of whitespace in front of some of the elements. I know this is fairly simple, I am not entirely new to the programming world, but I am new to vba in Excel and from prior experiences working with macros, there is a ton of built in functions that I am unaware of and they makes tasks like these pretty simple. (excuse the run-on :-D ) Here is the block that handles my count elements/load into array (feel free to correct it if there is a simpler route):
'Count Elements, dimension element array to appropriate size
n = 7
eCount = 0
Do While Worksheets("Costs Incurred").Cells(n, 2) <> ""
If Worksheets("Costs Incurred").Cells(n, 2) <> "" Then
eCount = eCount + 1
End If
n = n + 1
Loop
ReDim elements(1 To eCount)
'Load Element names into Element Array
n = 1
Do While n <= eCount
elements(n) = Worksheets("Costs Incurred").Cells(n + 6, 2)
n = n + 1
Loop
Thanks for any help!