Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 471
Default Select Range

In my code I determine a range that I wish to select. What is the proper
syntax to select that range. Let's say I wish to add a line to all cells
selected. This does not work:
My hope would be to have every cell from 11,1 to 65,7 selected but I get an
error on the line Range(PrtRng).select. Ideas?

Dim PrtRng as Range
Dim X as Double
let X=65
Set PrtRng = Range(Cells(11, 1), Cells(X, 7))
Range(PrtRng).Select
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Select Range

You don't need range, use this

PrtRng.Select

Mike

"Mike H." wrote:

In my code I determine a range that I wish to select. What is the proper
syntax to select that range. Let's say I wish to add a line to all cells
selected. This does not work:
My hope would be to have every cell from 11,1 to 65,7 selected but I get an
error on the line Range(PrtRng).select. Ideas?

Dim PrtRng as Range
Dim X as Double
let X=65
Set PrtRng = Range(Cells(11, 1), Cells(X, 7))
Range(PrtRng).Select
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Select Range

Sub mersion()
Dim PrtRng As Range
Dim X As Double
Let X = 65
Set PrtRng = Range(Cells(11, 1), Cells(X, 7))
PrtRng.Select
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With

End Sub

You don't need the RANGE() in the Select line because PrtRng is already a
range.


You use RANGE() to convert an address (usually a String) into a range.
--
Gary''s Student - gsnu200764


"Mike H." wrote:

In my code I determine a range that I wish to select. What is the proper
syntax to select that range. Let's say I wish to add a line to all cells
selected. This does not work:
My hope would be to have every cell from 11,1 to 65,7 selected but I get an
error on the line Range(PrtRng).select. Ideas?

Dim PrtRng as Range
Dim X as Double
let X=65
Set PrtRng = Range(Cells(11, 1), Cells(X, 7))
Range(PrtRng).Select
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Select Range

Dim PrtRng As Range
Dim X As Double
Let X = 65
Set PrtRng = Range(Cells(11, 1), Cells(X, 7))
With PrtRng
With .Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With .Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
End With


--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Mike H." wrote in message
...
In my code I determine a range that I wish to select. What is the proper
syntax to select that range. Let's say I wish to add a line to all cells
selected. This does not work:
My hope would be to have every cell from 11,1 to 65,7 selected but I get
an
error on the line Range(PrtRng).select. Ideas?

Dim PrtRng as Range
Dim X as Double
let X=65
Set PrtRng = Range(Cells(11, 1), Cells(X, 7))
Range(PrtRng).Select
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 789
Default Select Range

On Jan 10, 10:13*am, Mike H. wrote:
In my code I determine a range that I wish to select. *What is the proper
syntax to select that range. *Let's say I wish to add a line to all cells
selected. *This does not work:
My hope would be to have every cell from 11,1 to 65,7 selected but I get an
error on the line Range(PrtRng).select. *Ideas?

Dim PrtRng as Range
Dim X as Double
let X=65
Set PrtRng = Range(Cells(11, 1), Cells(X, 7))
Range(PrtRng).Select
With Selection.Borders(xlEdgeBottom)
* * *.LineStyle = xlContinuous
* * *.Weight = xlThin
* * *.ColorIndex = xlAutomatic
End With


Hi
The Syntax Range(something) expects the something to be text e.g.
Range ("A1:B10"). You have already set your range object PrtRng so you
simply do

PrtRng.Select

(which, if you were a bit perverse, you might write as
Range(PrtRng.Address).Select if you want to see the text in there)

Note that you don't need to select the range object to work with it.
You could simply do

With PrtRng.Borders(xlEdgeBottom)
etc

regards
Paul
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can change range to select active rows instead of :=Range("S10 ldiaz Excel Discussion (Misc queries) 7 August 29th 08 03:52 PM
Find End in Undefined Range Select Range Trim SteveT Excel Programming 4 November 29th 07 06:54 PM
When entering data into a range of cells, select the entire range. Q Excel Discussion (Misc queries) 0 September 26th 07 04:36 AM
Compare a selected Range with a Named range and select cells that do not exist PCLIVE Excel Programming 1 October 18th 05 07:09 PM
Select Sheet then Select Range Gee[_2_] Excel Programming 3 May 27th 04 10:10 PM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"