ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   With statement parameters (https://www.excelbanter.com/excel-programming/373911-statement-parameters.html)

Arnold Klapheck

With statement parameters
 
I am getting an error message of, "wrong number of arguments or invalid
property assignment" and .Borders is highlighted. see between *@. I was
hoping to avoid having a separate with statement for every xlEdgeLeft,
xlEdgeTop etc. Can someone let me know if it can be done this way and what
I need to do to make it work? thanx

With Range("A1:AQ1")
.NumberFormat = "General"
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
With *@.Borders*@(xlEdgeLeft, xlEdgeTop, xlEdgeBottom, xlEdgeRight,
xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With .Font
.Name = "Arial"
.Size = 8
.Bold = False
.ColorIndex = xlAutomatic
End With
With .Interior
.ColorIndex = 15
.Pattern = xlSolid
End With
End With

Tom Ogilvy

With statement parameters
 

v = Array(xlEdgeLeft, xlEdgeTop, xlEdgeBottom, xlEdgeRight, xlInsideVertical)
for i = lbound(v) to ubound(v)
With .Borders(v(i))
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
Next
With .Font
.Name = "Arial"
.Size = 8
.Bold = False
.ColorIndex = xlAutomatic
End With
With .Interior
.ColorIndex = 15
.Pattern = xlSolid
End With
End With


--
Regards,
Tom Ogilvy

"Arnold Klapheck" wrote:

I am getting an error message of, "wrong number of arguments or invalid
property assignment" and .Borders is highlighted. see between *@. I was
hoping to avoid having a separate with statement for every xlEdgeLeft,
xlEdgeTop etc. Can someone let me know if it can be done this way and what
I need to do to make it work? thanx

With Range("A1:AQ1")
.NumberFormat = "General"
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
With *@.Borders*@(xlEdgeLeft, xlEdgeTop, xlEdgeBottom, xlEdgeRight,
xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With .Font
.Name = "Arial"
.Size = 8
.Bold = False
.ColorIndex = xlAutomatic
End With
With .Interior
.ColorIndex = 15
.Pattern = xlSolid
End With
End With


Arnold Klapheck

With statement parameters
 
Thanks, that worked, I just needed to:
Dim v As Variant
Dim i As Integer

I have option explicit on. if these are the wrong type let me know otherwise
response is not necessary, again thanx


All times are GMT +1. The time now is 10:19 AM.

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