ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   inserting a colored row with the department name (https://www.excelbanter.com/excel-programming/372582-inserting-colored-row-department-name.html)

Janis

inserting a colored row with the department name
 
This piece of code works in my macro however I need the interior color of the
row to be gray. I tried .interior.colorindex = gray after the insert and it
did it but then stopped and I got an error. Also, the name of the department
is in what is row 2, cell 17, but after the header row is inserted then it is
now row 3. This name is the value of the row header.
In this code it does not put the value in the row. I want it to be in the
center of the row.
Thanks very much for your help,

..Rows(2).Insert.Interior.ColorIndex = 15

With .Cells(3, 4)
.Value = .Cells(3, 17)
.Font.Bold = True
.Font.Size = 14
.RowHeight = 18
.Font.Color = vbWhite
End With

JLGWhiz

inserting a colored row with the department name
 
Not quite sure what you are trying with : .Rows(2).Insert.Interior.ColorIndex
= 15

To get gray in row 2 use: ActiveSheet.Rows(2).Interior.ColorIndex = 15

To align text in the center horizontally, add this line of code in your With
statment:

.HorizontalAlignment = xlHAlignCenter

"Janis" wrote:

This piece of code works in my macro however I need the interior color of the
row to be gray. I tried .interior.colorindex = gray after the insert and it
did it but then stopped and I got an error. Also, the name of the department
is in what is row 2, cell 17, but after the header row is inserted then it is
now row 3. This name is the value of the row header.
In this code it does not put the value in the row. I want it to be in the
center of the row.
Thanks very much for your help,

.Rows(2).Insert.Interior.ColorIndex = 15

With .Cells(3, 4)
.Value = .Cells(3, 17)
.Font.Bold = True
.Font.Size = 14
.RowHeight = 18
.Font.Color = vbWhite
End With


Janis

inserting a colored row with the department name
 
thanks,

"JLGWhiz" wrote:

Not quite sure what you are trying with : .Rows(2).Insert.Interior.ColorIndex
= 15

To get gray in row 2 use: ActiveSheet.Rows(2).Interior.ColorIndex = 15

To align text in the center horizontally, add this line of code in your With
statment:

.HorizontalAlignment = xlHAlignCenter

"Janis" wrote:

This piece of code works in my macro however I need the interior color of the
row to be gray. I tried .interior.colorindex = gray after the insert and it
did it but then stopped and I got an error. Also, the name of the department
is in what is row 2, cell 17, but after the header row is inserted then it is
now row 3. This name is the value of the row header.
In this code it does not put the value in the row. I want it to be in the
center of the row.
Thanks very much for your help,

.Rows(2).Insert.Interior.ColorIndex = 15

With .Cells(3, 4)
.Value = .Cells(3, 17)
.Font.Bold = True
.Font.Size = 14
.RowHeight = 18
.Font.Color = vbWhite
End With



All times are GMT +1. The time now is 10:48 PM.

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