problem referring to Range and Cells
Kevin,
The problem is in the With line, as the Calls property is not qualified, so
it refers to the activesheet.
Try this version
Sub test()
Dim Message As String
Message = MsgBox("This test # 1")
With Worksheets("Sheet2")
With .Range(.Cells(3, 1), .Cells(3, 5))
Message = MsgBox("This test # 2")
With .Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
End With
End With
End Sub
--
HTH
Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
"Kevin" wrote in message
...
The program halts and I get a Run-time error '1004' when I run the
following
code from Sheet1. But it works fine when I run it from Sheet2. Any
ideas?
Thanks.
Kevin
Sub test()
Dim Message As String
Message = MsgBox("This test # 1")
With Worksheets("Sheet2").Range(Cells(3, 1), Cells(3, 5))
Message = MsgBox("This test # 2")
With .Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
End With
End Sub
|