PDA

View Full Version : Solved: Help with this code?



Djblois
05-10-2007, 12:25 PM
I don't know what to call this? I am coloring column headings but many times they are different sizes so I am using this:

Sub ColorColumnHeadings(ByVal rngColumnHeading As Range)
With rngColumnHeading
.Font.ColorIndex = 2
.Interior.ColorIndex = 5
.Font.Bold = True
.HorizontalAlignment = xlCenter
End With
End Sub

Sub ColumnHeadingsCommon()

ColorColumnHeadings (Range(Range("IV1").End(xlToLeft), "A1"))
'With Range(Range("IV1").End(xlToLeft), "A1")
' .Font.ColorIndex = 2
' .Interior.ColorIndex = 5
' .Font.Bold = True
' .HorizontalAlignment = xlCenter
'End With

End Sub

the commented out code is the code I am trying to get rid of. Currently it is giving me an error. I don't even know how to look this up in the help files or search on here? What is it called when you use (byval ??????? by ?????)?

Djblois
05-10-2007, 12:50 PM
sorry everyone I figured it out but can someone still tell me what to call it?

Paul_Hossler
05-11-2007, 08:10 AM
Call what?

Paul

Bob Phillips
05-11-2007, 08:17 AM
Your original code works fine. What error do you get?

Djblois
05-11-2007, 10:28 AM
Xld,

I changed this:



Sub ColumnHeadingsCommon()


ColorColumnHeadings (Range(Range("IV1").End(xlToLeft), "A1"))
'With Range(Range("IV1").End(xlToLeft), "A1")
' .Font.ColorIndex = 2
' .Interior.ColorIndex = 5
' .Font.Bold = True
' .HorizontalAlignment = xlCenter
'End With


End Sub


to this:



Sub ColumnHeadingsCommon()


ColorColumnHeadings Range(Range("IV1").End(xlToLeft), "A1")
'With Range(Range("IV1").End(xlToLeft), "A1")
' .Font.ColorIndex = 2
' .Interior.ColorIndex = 5
' .Font.Bold = True
' .HorizontalAlignment = xlCenter
'End With


and now it works


End Sub

Bob Phillips
05-11-2007, 11:16 AM
Maybe, but what error did you originally get to force you down that path.

Charlize
05-11-2007, 04:07 PM
Function needed an object for me, I changed it to this :Sub ColumnHeadingsCommon()
ColorColumnHeadings (ActiveSheet.Range("A1:IV1"))
End Sub