ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Inserting column headers (https://www.excelbanter.com/excel-programming/312024-inserting-column-headers.html)

steve

Inserting column headers
 
How would I write a macro that:

i)Inserts a new row in row 1 of my spreadsheet
ii)Places columns names in A1 ("Surname"),B1 ("First
Name") & C1 ("Score") and Bolds them.

Thanks in advance


Ron de Bruin

Inserting column headers
 
Try this

Sub test()
With ActiveSheet
.Range("A1").EntireRow.Insert
.Range("A1").Value = "Surname"
.Range("B1").Value = "First Name"
.Range("C1").Value = "Score"
.Range("A1:C1").Font.Bold = True
End With
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Steve" wrote in message ...
How would I write a macro that:

i)Inserts a new row in row 1 of my spreadsheet
ii)Places columns names in A1 ("Surname"),B1 ("First
Name") & C1 ("Score") and Bolds them.

Thanks in advance




Tom Ogilvy

Inserting column headers
 
rows(1).Insert
Range("A1:C1").Value = Array("Surname","First Name","Score")
Range("A1:C1").font.bold = True

--
Regards,
Tom Ogilvy

"Steve" wrote in message
...
How would I write a macro that:

i)Inserts a new row in row 1 of my spreadsheet
ii)Places columns names in A1 ("Surname"),B1 ("First
Name") & C1 ("Score") and Bolds them.

Thanks in advance




steve

Inserting column headers
 
Thanks Ron
-----Original Message-----
Try this

Sub test()
With ActiveSheet
.Range("A1").EntireRow.Insert
.Range("A1").Value = "Surname"
.Range("B1").Value = "First Name"
.Range("C1").Value = "Score"
.Range("A1:C1").Font.Bold = True
End With
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Steve" wrote in

message ...
How would I write a macro that:

i)Inserts a new row in row 1 of my spreadsheet
ii)Places columns names in A1 ("Surname"),B1 ("First
Name") & C1 ("Score") and Bolds them.

Thanks in advance



.



All times are GMT +1. The time now is 02:30 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com