Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
69 views3 pages

Excel VBA Header Row

The document describes a VBA macro that displays the contents of a header row in an Excel spreadsheet. The macro defines range variables to select the header row, counts the number of cells, and uses a For/Next loop to display a message box with the content of each cell from left to right. The macro provides a simple way to view header information programmatically in VBA.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
69 views3 pages

Excel VBA Header Row

The document describes a VBA macro that displays the contents of a header row in an Excel spreadsheet. The macro defines range variables to select the header row, counts the number of cells, and uses a For/Next loop to display a message box with the content of each cell from left to right. The macro provides a simple way to view header information programmatically in VBA.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Houston Seminar in Excel VBA Macros

Excel VBA Macro to display the content


of a header row.

Sergio Perez Rodriguez


EG, PDG, MSc

April 2020
A macro to display the content in the cells of a header row can be setup as follows:

Sub MacroHead()

‘Definition of the variables

Dim he as Range

Dim v, ch as Integer

‘Selection of the header row and its assignment to the Range variable

Range("A1").Select

Range(Selection, Selection.End(xlToRight)).Select

Set he = Selection

‘Assignment to an integer variable of the number of cells in the header row

ch = he.Columns.Count

‘Loop to display the content in the cells of the header row

For v = 1 To ch

MsgBox "Header " & v & " is " & he(1, v)

Next v

End Sub
Bibliography

Jelen, B., Syrstad, T. 2016. Excel 2016 VBA and Macros. Pearson Education.

You might also like