VBA: Identify Header Row

ExcelKnut

Board Regular
Joined
Apr 18, 2013
Messages
144
I'm building a tool to accommodate various reports where the the header row could be in row 1, 2, 3 etc. This tool will be used by a number of different employees. I need a creative way (using VBA) to determine what row the header is in. Management has asked me to prevent the macro from running if there are less than 10 records on the report but each report has a header row and it could have a title etc.

BTW, users are only able to paste into cell A1.
 
Last edited:

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Need more information.

You could search for something that would only appear in the header. For example this will tell you the row number that "This will only be in the header" is in in column A
Code:
rnum = Application.Match("This will only be in the header", Range("A1:A3"), 0)
 
Upvote 0
Scott, thank you for your suggestion.

Unfortunately, there's no predictable wording. These reports and their fields/headers are all different so there's no way for me to search for certain text.
 
Upvote 0
Will the header be the first non blank row?


Code:
rnum = Range("A1").End(xlDown).Row
 
Upvote 0

Forum statistics

Threads
1,216,172
Messages
6,129,291
Members
449,498
Latest member
Lee_ray

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