![]() |
![]() |
|
|||||||
| 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 |
|
New Member
Join Date: Apr 2002
Location: Adam
Posts: 9
|
I have a spread sheet that I need to select a range of cells The goal is to create this selection based on the the last position of data on the first column, I now how to do this with rows but unable to to do this with this situation.
Thanks Please let me know if you need futher clarification. Please a see the table below. J K L M N Symbol Company Name Last High Low Volume High Low lwin lwin THIS IS THE AREA NEED TO SELECT THE SELECTION SHOULD START K3 & END ON COLUMN Z BASED ON THE LAST CELL REFERENCE THAT HAS DATA FROM COLUMN J , THIS WILL CHANGE EVERY DAY. lwin lwin lwin lwin lwin lwin LAST CELL REF |
|
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Mar 2002
Location: Chicago, IL USA
Posts: 2,042
|
Hi,
Try, Sub test() Dim lastrow As Long lastrow = Cells(Rows.Count, "J").End(xlUp).Row Cells(lastrow, "J").Offset(0, 1).Resize(1, 16).Select End Sub HTH, Jay |
|
|
|
|
|
#3 |
|
New Member
Join Date: Apr 2002
Location: Adam
Posts: 9
|
Thanks that worked out great!
|
|
|
|
|
|
#4 |
|
New Member
Join Date: Apr 2002
Location: Adam
Posts: 9
|
One more question. Now that I have selected the bottom of the area I want, how do I basically hold downt he shift key and select the range up to one row before the top?
|
|
|
|
|
|
#5 |
|
MrExcel MVP
Join Date: Mar 2002
Location: Chicago, IL USA
Posts: 2,042
|
Hi,
Rewrite the routine to do what you want. I don't know exactly what you need, so try the following. I have commented out another option, too. '------------- Sub test() Dim lastrow As Long, firstrow As Long lastrow = Cells(Rows.Count, "J").End(xlUp).Row firstrow = Cells(lastrow, "J").End(xlUp).Row If lastrow = 1 Then Cells(lastrow, "J").Offset(0, 1).Resize(1, 16).Select Else Range(Cells(2, "K"), Cells(lastrow, "Z")).Select '''' or use something like this '''' Range(Cells(firstrow + 1, "K"), Cells(lastrow, "Z")).Select End If End Sub '-------------- Bye, Jay |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|