![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Mar 2002
Posts: 1,288
|
I have a macro with the following procedure:
Set kopi = Range("A4:" & Range("K65536").End(xlUp).Address) What I want to do is indicate the range not only to the laste row,but also to the last column.With other word the hole sheet set to make a copy. Can somebody help? Thanks in advance |
|
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Columbus, OH, USA
Posts: 3,519
|
Why not just try the "UsedRange" property?
|
|
|
|
|
|
#3 | |
|
Board Regular
Join Date: Mar 2002
Posts: 1,288
|
Quote:
Thanks. |
|
|
|
|
|
|
#4 |
|
MrExcel MVP
Join Date: Mar 2002
Location: Chicago, IL USA
Posts: 2,042
|
Try this and adjust to your needs.
Sub test() Dim kopi As Range Set kopi = ActiveSheet.UsedRange kopi.Select End Sub HTH, Jay |
|
|
|
|
|
#5 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Columbus, OH, USA
Posts: 3,519
|
Is there any data in your first three rows? I'm basing this on the fact that you used A4 as the first cell in your range. Anyway, I've assumed that there's no data in the first three rows, if this is wrong, just repost. Here's how to use "UsedRange":
|
|
|
|
|
|
#6 | |
|
Board Regular
Join Date: Mar 2002
Posts: 1,288
|
Quote:
Any idea to do this? Thanks. |
|
|
|
|
|
|
#7 |
|
MrExcel MVP
Join Date: Mar 2002
Location: Chicago, IL USA
Posts: 2,042
|
Try,
Sub test() Dim kopi As Range Code:
Set kopi = Intersect(ActiveSheet.Rows("5:" & Rows.Count), _
ActiveSheet.UsedRange)
kopi.Select
End Sub
|
|
|
|
|
|
#8 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Columbus, OH, USA
Posts: 3,519
|
verluc, this will do it:
HTH EDIT:: Sh!t nice code Jay. _________________ [b] Mark O'Brien [ This Message was edited by: Mark O'Brien on 2002-05-07 16:42 ] |
|
|
|
|
|
#9 | |
|
Board Regular
Join Date: Mar 2002
Posts: 1,288
|
Quote:
|
|
|
|
|
|
|
#10 |
|
Join Date: May 2002
Posts: 20
|
Alternatively :-
Set kopi = Range([A4], Cells.SpecialCells(xlCellTypeLastCell)) Which works whether or not any of the rows 1:3 are blank. Or, to make sure the last cell has been reset first :- Activesheet.UsedRange Set kopi = Range([A4], Cells.SpecialCells(xlCellTypeLastCell)) |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|