I have a text file that contains information regarding business units. Field headings being: BUnit, Account, Descr and Amt. Each business unit in the text file has a different number of lines.
What I am trying to achieve is to run different code when the business unit changes. I have attempted to write different lines of code to account for the business unit change but have not come up with a sound approach.
Dim LineofText As String
FileToOpen = Application.GetOpenFilename("Text Files (*.txt), *.txt")
Open FileToOpen For Input As #1
Do While Not EOF(1)
Line Input #1, LineofText
Sheets("Sheet1").Range("TextLine") = LineofText
oVar = Split(Sheets("Sheet1").Range("TextLine"), ",")
oBUnitNew = oVar(0)
If oBUnitNew<> oBUnitPrior Then RunDifferentCode Keep on reading text file until the business unit changes; then run some code
oBUnitPrior = oBunitNew
Any assistance would be appreciated.