Question on finding headers when opening workbooks

jaybee3

Active Member
Joined
Jun 28, 2010
Messages
307
I have a workbook (well a host of workbooks) I need to import. The thing is, the headers aren't always in the same column. They are however always the same name.

I'm currently using a find to get the positions of the columns I need to then retrieve the data I want.

Something along the lines of:

Code:
For ii = lbound(aHeaders) to ubound(aHeaders)
 
   Set rHeader = wbSrc.sheets("Data").rows(1).specialcells(xlcelltypeconstants).find(aHeaders(ii),,,xlWhole)
 
  If not rHeader is nothing then
 
  ...perform calcs..
 
  End if
 
Next ii

I was wondering if there was a (faster) alternative? Aside from having the reports sent in the same format?
 
I don't believe you'll find a faster way to "find" the headers that would make a perceptable difference.

If all you are doing for this step is copying the data under each field, then you might consider AdvancedFilter.
It would probably be faster than copying each column separately.
 
Upvote 0
Alright cheers for the info. Yeah I've found that (advanced) filters are quick on large datasets, I'll try that :)
 
Upvote 0

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top