Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Creating a Changing Range

Just to be neat about it.

Sub gj()
Dim Rng As String, Rng1 As String, myRange As Range

Rng = ActiveSheet.UsedRange.Address
Rng1 = Right(Rng, Len(Rng) - InStr(Rng, ":"))
Set myRange = Range("B8:" & Rng1)
MsgBox myRange.Address
End Sub

In case you use Option Explicit.


"James" wrote:

Thanks for the link, Tim. I tried this but cant seem to refrence it in my
code. i did a simple MsgBox MyRange.Address and it says 'object required' The
proper range is being selected when I do Insert-Name-Range. Is there a
special way to refrence it in the code. Couldnt find it on the page you gave
me. thx

JLGWhiz, I tried your version and it would work great but it selects
Range("A1:T373"), I want it to select only Range("B8:T373"). Could I do
something like

Set Rng = ActiveCell.CurrentRegion
Set MyRange=Rng.Offset(8,1).Resize(Rng.Rows.Count-8,Rng.Columns.Count-1)
MsgBox MyRange.Address

when i try this i get a "1004 application or object defined error"

================================================== ===

"Tim" wrote:

you could try a 'dynamic named range' and refer to that in your
code/worksheet: -

http://www.ozgrid.com/Excel/DynamicRanges.htm

you just need to be careful about which rows/columns you choose to base the
range on (ie, they have to be ones that will always have an entry, otherwise
the 'shape' of the range will be wrong).

hth,

Tim


"James" wrote in message
...
Hi everyone, Maybe a quick question. How do I create a range that knows
exactly how big the data range is? I Want the range to start at "B8" and
go
to Last used row, and last used column. Is this possible? Thanks!




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
Changing the range for averages with out changing the formula. JessLRC Excel Worksheet Functions 0 April 20th 10 03:10 PM
Autofill 1 column with changing data and changing range cdclayton Excel Programming 0 August 5th 08 04:37 PM
Incrementing no.s creating new but not changing no. opening saved ml123 Excel Discussion (Misc queries) 2 April 18th 08 03:52 PM
Creating an changing scale on x axis for outlying cases Steve BBC UK Charts and Charting in Excel 1 December 12th 06 01:24 PM
Changing the comma for a semicolon when creating a CSV file Peter Rooney Excel Programming 3 August 11th 05 09:23 AM


All times are GMT +1. The time now is 05:26 AM.

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

About Us

"It's about Microsoft Excel"