ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   passing Excel system values (constant) of properties as arguments (https://www.excelbanter.com/excel-programming/320852-passing-excel-system-values-constant-properties-arguments.html)

ROland

passing Excel system values (constant) of properties as arguments
 
I want to pass system constants as arguments to a procedure or function. In
my case, I want to pass the constants xlThick/xlMedium of the 'Weight'
property to a procedure.
How do I have to do this?
many thanks
roland

Lonnie M.

passing Excel system values (constant) of properties as arguments
 
Roland, this is how I have handled it:

Sub Test()
Call BoxBorder(xlThin)
End Sub

Public Sub BoxBorder(myWeight As Variant)
With Selection.Borders(xlEdgeLeft)
..LineStyle = xlContinuous
..Weight = myWeight
..ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
..LineStyle = xlContinuous
..Weight = myWeight
..ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
..LineStyle = xlContinuous
..Weight = myWeight
..ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
..LineStyle = xlContinuous
..Weight = myWeight
..ColorIndex = xlAutomatic
End With
End Sub


HTH--Lonnie M.


Rob van Gelder[_4_]

passing Excel system values (constant) of properties as arguments
 
Just noted your example - in case you didn't know, the Range object has a
method called BorderAround
eg.
Selection.BorderAround Weight:=xlThick

--
Rob van Gelder - http://www.vangelder.co.nz/excel


"Lonnie M." wrote in message
oups.com...
Roland, this is how I have handled it:

Sub Test()
Call BoxBorder(xlThin)
End Sub

Public Sub BoxBorder(myWeight As Variant)
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = myWeight
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = myWeight
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = myWeight
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = myWeight
.ColorIndex = xlAutomatic
End With
End Sub


HTH--Lonnie M.




Lonnie M.

passing Excel system values (constant) of properties as arguments
 
Thanks--I am always on the lookout for a better way, and you certainly
provided one.



All times are GMT +1. The time now is 05:26 PM.

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