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 / General Excel Questions / April 2008

Tip: Looking for answers? Try searching our database.

Change a specific code to generic in VB macro

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Sue - 23 Apr 2008 18:06 GMT
I have the following:

Selection.AutoFill Destination:=Range("BE2:BE567"), Type:=xlFillDefault
   Range("BE2:BE567").Select

I would like to change the code to include all possible used cells to fill.
How do I do this?

Signature

Sue

gt - 23 Apr 2008 18:19 GMT
Hi Sue:

Here's one approach.

Use a line of code like this to find the last used row:

   LastRow = Range("B65536").End(xlUp).row       OR
   LastRow = ActiveCell.SpecialCells(xlLastCell).row

Then modify your code to this:

Selection.AutoFill Destination:=Range("BE2:BE" & Lastrow), Type:=xlFillDefault
    Range("BE2:BE" & Lastrow).Select

Give that a whirl.

cheers,
gt

> I have the following:
>
[quoted text clipped - 3 lines]
> I would like to change the code to include all possible used cells to fill.
> How do I do this?
gt - 23 Apr 2008 18:56 GMT
ooops - one slight change :

>     LastRow = Range("BE65536").End(xlUp).row       OR
>     LastRow = ActiveCell.SpecialCells(xlLastCell).row
[quoted text clipped - 3 lines]
> Selection.AutoFill Destination:=Range("BE2:BE" & Lastrow), Type:=xlFillDefault
>      Range("BE2:BE" & Lastrow).Select

> Hi Sue:
>
[quoted text clipped - 22 lines]
> > I would like to change the code to include all possible used cells to fill.
> > How do I do this?
 
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.