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

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
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,223,716
Messages
6,174,069
Members
452,542
Latest member
Bricklin

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