Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / May 2008

Tip: Looking for answers? Try searching our database.

Last Row of Data

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
vivi - 29 May 2008 11:00 GMT
hi

I have a slight problem with my code...any help will be appreciated

I have written some codes and use it for vairous workbooks, however, I must
have written something incorrectly as my the orignal code was written for a
workbook with 853 records, after I have copied the modules to the other
workbooks, they all look fine on Excel, i want to check my copied modules are
working fine and so I press Ctrl+down and went to my last record (26 records)
which is all fine. However, I notice only when I export to Access that the
last record was 853, i.e. it creates 827 blank rows in Access. Therefore I
went back to my Excel fine and press Ctrl+End and found out the record indeed
say my last cell was 853.

I am not sure what I need to do but think if I can write vba to delete all
rows and columns after my last record I should be fine (I have manually done
this and checked Access that it does indeed work!) I am struggle with the vba
code, I tried to use this:

Range("A1").Select
Selection.End(xlDown).Select
Selection.End(xlDown).Select
Selection.End(xlUp).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Delete Shift:=xlUp

However, it deletes my last record and only column A...what do i need to do???

Please help!! Thanks a lot

P.S. I have only just started and learned vba, please be a bit patient with
me if I sound stupid......

Vivian
Mike Fogleman - 29 May 2008 11:40 GMT
See this article on how to clear the used range:

http://www.contextures.com/xlfaqApp.html#Unused

Mike F
> hi
>
[quoted text clipped - 39 lines]
>
> Vivian
vivi - 29 May 2008 11:50 GMT
Thanks a lot...finally has a solution for my problem :) Have a nice day!!!

> See this article on how to clear the used range:
>
[quoted text clipped - 44 lines]
> >
> > Vivian
Mike H - 29 May 2008 11:49 GMT
Hi,

I'm not completely clear what your trying to do but this will select
everything from the first blank cell in Column A to the last cell. If it does
what you want then change .Select to .Delete and you can do it all in one
line.

Range(Range("A" & Columns(1).SpecialCells(xlCellTypeBlanks)(1, 1).Row), _
Range("A" & Cells(Cells.Rows.Count, "A").End(xlDown).Row)).Select

Mike

> hi
>
[quoted text clipped - 30 lines]
>
> Vivian
Ron de Bruin - 29 May 2008 20:10 GMT
See also
http://www.rondebruin.nl/last.htm

Signature

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm

> hi
>
[quoted text clipped - 30 lines]
>
> Vivian
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.