vba_n00b
vba_n00b

Reputation: 53

1004 error for range argument

I have another simple syntax question that I can't quite figure out. I want to change all the cells in a column so they have a bottom border and have a variable to figure out the last night with data on it.

My code is below and I believe the error is how I am trying to define the last cell.

wsSheet.Range("F11:wsSheet.Cells(LastRowForSig, 6)").Borders(xlEdgeBottom).LineStyle = xlContinuous

Upvotes: 0

Views: 76

Answers (3)

A.S.H
A.S.H

Reputation: 29332

Try this:

With wsSheet.Range("F11", wsSheet.Cells(LastRowForSig, 6)).Borders
    .value = 1
    .item(xlEdgeLeft).LineStyle = xlNone
    .item(xlEdgeRight).LineStyle = xlNone
    .item(xlEdgeTop).LineStyle = xlNone
End With

Upvotes: 0

SJR
SJR

Reputation: 23081

You should accept E. Trauger's answer, but here is a slight variation

With wsSheet
    .Range("F11", .Cells(LastRowForSig, 6)).Borders(xlEdgeBottom).LineStyle = xlContinuous
End With

Upvotes: 1

ERT
ERT

Reputation: 729

Try this code below

Dim r1 as Range, r2 as Range
Set r1 = wsSheet.Range("F11")
Set r2 = wsSheet.Cells(LastRowForSig, 6)

wsSheet.Range(r1 & ":" & r2).Borders(xlEdgeBottom).LineStyle = xlContinuous

Edited after request.

Upvotes: 0

Related Questions