|
-
May 3rd, 2006, 10:26 AM
#1
Thread Starter
Member
Can you read to EOF in excel??
I can read any cell I specify, but can you read to the end of the excell file??
Is that possible??
-
May 3rd, 2006, 01:36 PM
#2
Re: Can you read to EOF in excel??
Welcome to the Forums.
Yes, but what exactly are you needing to do? You can do this several ways.
There is the .UsedRange function or the .SpecialCells function. Which to use will depend on your needs but both will work.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
May 4th, 2006, 06:29 AM
#3
Thread Starter
Member
Re: Can you read to EOF in excel??
Here's the deal... 
I have two spreadsheets I'm reading in two different workbooks.
I'm having to read each sheet, and then put them each into the same dataSet. But each goes into its own dataTable. Then I need to compare them once I've done that.
I can do this if I know exactly how many rows are in each spreadsheet, but the problem is these are going to change, maybe daily. So I need to be able to read to EFO of the spreadsheets, then where there is no more data, stop.
Can I use UsedRange or .SpecialCells for this? Or is there any other function or way?
-
May 4th, 2006, 03:50 PM
#4
Lively Member
Re: Can you read to EOF in excel??
Here's a step-by-step instruction from MS that shows 2 methods for finding the end of existing data:
http://www.microsoft.com/technet/scr.../tips0421.mspx
I think this will help you with what you are trying to do.
EDIT:
This instruction is actually for appending data to an existing data range, but it still shows you how to find the end of your existing data.
Last edited by New2vba; May 8th, 2006 at 01:08 PM.
"Those things we must learn to do, we must learn by doing" (or hope somebody else will take pity and help out )
-
May 9th, 2006, 03:42 AM
#5
Re: Can you read to EOF in excel??
If you can guarantee that one of the columns will have data in every cell you can use
Code:
set rng = sht.cells(1,1).End(xlDown)
or
Code:
set rng = sht.cells(65535,1).End(xlUp)
Then you can get the row with
Code:
debug.print rng.row
Another option...
rng is a range object
sht is a worksheet
Cells is an Excel method.
xlUp/Down are variables declared in Excel.
This mimics the button presses : End, then Down/Up from cell A1/A65535 (depending if you are going up or down).
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|