Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Excel VBA - Found last row number but can't select it

Certainly applicable to appropriate situations, but it can be tripped up as
well by the occasional blank row or blank column.

--
Regards,
Tom Ogilvy

"MSP77079 " wrote in message
...
All of this works as long as no one has made any extraneous entries
below your data table. But, it's going to fail if the worksheet is
not absolutely, infallibly clean.

When I have a table of data, I don't use "search for *". Nor do I use
end(xlUp). Instead, I use "CurrentRegion". It is not fooled by the
occassional blank cell, nor extraneous stuff at the end of the
datatable.

Let's say that cell "B2" is the first cell in the data table. Then,

Set myRange = Range("B2").CurrentRegion
LastRow = myRange.Cells(myRange.Cells.Count).Row
LastCol = myRange.Cells(myRange.Cells.Count).Column

worksheets("Sheet3").Range("A2:AA2").Copy _
Destination:=worksheets("Sheet2").Cells(LastRow, LastCol)


---
Message posted from http://www.ExcelForum.com/



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
Extract number from cell when specific format is found paul c Excel Worksheet Functions 6 August 2nd 09 03:45 AM
Count the number of Commas found in cell A2 B~O~B Excel Worksheet Functions 3 April 2nd 08 05:27 PM
How to select the number in excel? Eric Excel Worksheet Functions 5 March 13th 06 06:58 AM
Advanced Filter: Number of Records Found Charlie Rowe Excel Discussion (Misc queries) 2 November 3rd 05 09:09 PM
is there someway to select what i have "found"? 1stpope New Users to Excel 1 March 16th 05 03:27 AM


All times are GMT +1. The time now is 11:43 PM.

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"