View Full Version : What is the difference betweem Range and Usedrange ?
Nader
01-05-2008, 08:16 AM
What is the difference betweem Range and Usedrange ?
Bob Phillips
01-05-2008, 08:23 AM
Range is generic, it can apply to any set of cells within a worksheet.
Usedrange is specifice, it refers to the whole area of a worksheet bounded by the first and last cell input.
Homework?
Nader
01-05-2008, 03:16 PM
may you give some example please
UsedRange is a property of the worksheet.
It represents the range of cells that contain data.
If you open a new worksheet and put data (only) in cells B2, C3, D4, and E5.Then enter and run this simple test program
Sub Test()
Dim AnyRangeWeWant As Range
Set AnyRangeWeWant = ActiveSheet.Range("A1:A100")
Debug.Print AnyRangeWeWant.Address
Debug.Print ActiveSheet.UsedRange.Address
Set AnyRangeWeWant = ActiveSheet.Range("A1:Z999")
Debug.Print AnyRangeWeWant.Address
Debug.Print ActiveSheet.UsedRange.Address
End Sub
It should give you a feel for what UsedRange is. The range AnyRangeWeWant can be set to whatever you want, but UsedRange will always be "B2:E5" because it always represents the block of cells that
actually has data.
Nader
01-06-2008, 07:51 PM
Thank you for help.
By the way I put Msgbox instead of Debug.print to show the result.
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.