Declare first row as header for VBA

saschmeling

New Member
Joined
Jun 27, 2012
Messages
39
Hi,

I am working with VBA and automating a spreadsheet that we do. We import and SSRS report into Excel, then perform certain tasks on it. However for one of the lines, it is giving the following error:

Code:
Microsoft Excel Cannot determine which row in your list or selection contains column labels, which are required for this command.


Is there a way in VBA to set Row 1 as a header row?

Thanks in advance,
Scott
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
What do you see that message in response to?
 
Upvote 0
Here's the code I am running at that time:

<cells.subtotal groupby:="2," function:="xlSum," totallist:="Array(2," 6,="" 9,="" 12="" _
Code:
Cells.Subtotal GroupBy:=2, Function:=xlSum, TotalList:=Array(2, 6, 9, 12 _
        ), Replace:=True, PageBreaks:=False, SummaryBelowData:=False
Thanks</cells.subtotal>
 
Upvote 0
Try

Code:
Application.DisplayAlerts = False
' your code
Application.DisplayAlerts = True
 
Upvote 0
Likely a simple format of the headers will be adequate. That is often used within the spreadsheet to identify headers. Please try

cells.rows(1).font.bold = true

Or maybe some color too (for the header row only)

regards

post script : obviously I've assumed the headers are in row 1 of the worksheet
 
Last edited:
Upvote 0
The display alerts will just bypass you having to say its okay to continue - the message you get looks like a halt error that won't let you continue by using the suggested code. Did you make whatever this macro is by use of the macro recorder? It seems to me that your file structure is different now than when you recorded a macro (the pasted code reeks of macro recorder!).

My guess is that one of your columns is now lacking a heading and excel isn't sure what to do with it...
 
Upvote 0

Forum statistics

Threads
1,215,699
Messages
6,126,273
Members
449,308
Latest member
VerifiedBleachersAttendee

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