Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Set Range with Long Variable
I have 3 ranges I want to add vertical lines too, but I keep getting an error
that says "Wrong Number of Arguements or Invalid Property Assignment." Anyone know why? Is there a cleaner way to write out this range? Sub AddLines() Dim lngFirstRow As Long Dim lngLastRow As Long ' adds thin vertical lines to separate columns With Range("B" & lngFirstRow & ":B" & lngLastRow, _ "F" & lngFirstRow & ":F" & lngLastRow, _ "H" & lngFirstRow & ":H" & lngLastRow) .Borders(xlEdgeLeft).Weight = xlThin .Borders(xlEdgeRight).Weight = xlThin End With End Sub -- Cheers, Ryan |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Set Range with Long Variable
Ryan,
see if this helps: Sub AddLines() Dim lngFirstRow As Long Dim lngLastRow As Long Dim MultiRange As Range Set MultiRange = Union(Range("B" & lngFirstRow & ":B" & lngLastRow), _ Range("F" & lngFirstRow & ":F" & lngLastRow), _ Range("H" & lngFirstRow & ":H" & lngLastRow)) ' adds thin vertical lines to separate columns With MultiRange .Borders(xlEdgeLeft).Weight = xlThin .Borders(xlEdgeRight).Weight = xlThin End With End Sub -- jb "Ryan H" wrote: I have 3 ranges I want to add vertical lines too, but I keep getting an error that says "Wrong Number of Arguements or Invalid Property Assignment." Anyone know why? Is there a cleaner way to write out this range? Sub AddLines() Dim lngFirstRow As Long Dim lngLastRow As Long ' adds thin vertical lines to separate columns With Range("B" & lngFirstRow & ":B" & lngLastRow, _ "F" & lngFirstRow & ":F" & lngLastRow, _ "H" & lngFirstRow & ":H" & lngLastRow) .Borders(xlEdgeLeft).Weight = xlThin .Borders(xlEdgeRight).Weight = xlThin End With End Sub -- Cheers, Ryan |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Set Range with Long Variable
Here is shorter way to write that Set statement for the MultiRange
variable... Set MultiRange = Intersect(Rows(lngFirstRow & ":" & _ lngLastCol), Range("B:B,F:F,H:H")) -- Rick (MVP - Excel) "john" wrote in message ... Ryan, see if this helps: Sub AddLines() Dim lngFirstRow As Long Dim lngLastRow As Long Dim MultiRange As Range Set MultiRange = Union(Range("B" & lngFirstRow & ":B" & lngLastRow), _ Range("F" & lngFirstRow & ":F" & lngLastRow), _ Range("H" & lngFirstRow & ":H" & lngLastRow)) ' adds thin vertical lines to separate columns With MultiRange .Borders(xlEdgeLeft).Weight = xlThin .Borders(xlEdgeRight).Weight = xlThin End With End Sub -- jb "Ryan H" wrote: I have 3 ranges I want to add vertical lines too, but I keep getting an error that says "Wrong Number of Arguements or Invalid Property Assignment." Anyone know why? Is there a cleaner way to write out this range? Sub AddLines() Dim lngFirstRow As Long Dim lngLastRow As Long ' adds thin vertical lines to separate columns With Range("B" & lngFirstRow & ":B" & lngLastRow, _ "F" & lngFirstRow & ":F" & lngLastRow, _ "H" & lngFirstRow & ":H" & lngLastRow) .Borders(xlEdgeLeft).Weight = xlThin .Borders(xlEdgeRight).Weight = xlThin End With End Sub -- Cheers, Ryan |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
http://CannotDeleteFile.net - Cannot Delete File? Try Long Path ToolFilename is too long? Computer Complaining Your Filename Is Too Long? TheLong Path Tool Can Help While most people can go about their businessblissfully unaware of the Windo | Excel Discussion (Misc queries) | |||
Can't insert a String Variable of Long Date into Page Header | Excel Programming | |||
setting a range variable equal to the value of a string variable | Excel Programming | |||
Loop a long formula through range | Excel Programming | |||
Problem trying to us a range variable as an array variable | Excel Programming |