I have an excel sheet where I can have columns between 200 to 260 range,means it is in dynamic nature. But there is two columns fixed which can always be in consecutive way- They are Hierarchy, Parent Business Process ID.My goal is to locate in which column it is in the first row.It would always be in the first Row – that is quite sure.But its column number is not fixed. So is there anyway to find out directly in which column of the first row it is present every time whenever my script would run. I am using basic looping technique to find it out – which is increasing overall performance my code- So i want to minimize it.
Code
columncount=1
Do untill ob6.Cells(1,columncount).Value = "Parent Business Process ID"
columncount=columncount+1
Loop
Thanks,
Assuming
ob6is your worksheet object:columncount = Application.WorksheetFunction.Match("Parent Business Process ID", ob6.Rows(1), 0)Will set
columncountto the number of the first column matching your search criteria.Note that if your first row does not include the search term, than an error will occur.