View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Kevin Kevin is offline
external usenet poster
 
Posts: 134
Default problem referring to Range and Cells

Work like a charm

Thanks very much Flemming

----- Flemming Dahl wrote: ----

Yes "Range(Cells(3, 1), Cells(3, 5))" is the problem

Try this

Sub test(
With Worksheets("Sheet2").Range(Range(Cells(3, 1), Cells(3
5)).Address).Borders(xlInsideVertical
.LineStyle = xlContinuou
.Weight = xlThi
.ColorIndex = xlAutomati
End Wit
End Su

Cheers
Flemmin



"Kevin" wrote in messag
..
I would like to affect Sheet2 without activating it. That is, I woul
like to affect Sheet2 when Sheet1 is the active sheet. It seems t
me "Range(Cells(3, 1), Cells(3, 5))" is the problem
Thanks
Kevi
----- Flemming Dahl wrote: ----
Your code only works for the ActiveSheet

You say i works fine form Sheet 2 - Try select Sheet 1 before runnin

it o
sheet 2 and then sheet
This will work
Sub test(

Worksheets("Sheet1").Activat
With Range(Cells(3, 1), Cells(3, 5)
With .Borders(xlInsideVertical
.LineStyle = xlContinuou
.Weight = xlThi
.ColorIndex = xlAutomati
End Wit
End Wit
End Su
Cheers

Flemmin
"Kevin" wrote in messag

..
The program halts and I get a Run-time error '1004' when I run th

followin
code from Sheet1. But it works fine when I run it from Sheet2

An
ideas
Thanks
Kevi
Sub test(

Dim Message As Strin
Message = MsgBox("This test # 1"
With Worksheets("Sheet2").Range(Cells(3, 1), Cells(3, 5)
Message = MsgBox("This test # 2"
With .Borders(xlInsideVertical
.LineStyle = xlContinuou
.Weight = xlThi
.ColorIndex = xlAutomati
End Wit
End Wit
End Su