Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
Sue Sue is offline
external usenet poster
 
Posts: 285
Default Change a specific code to generic in VB macro

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?

--
Sue
  #2   Report Post  
Posted to microsoft.public.excel.misc
gt gt is offline
external usenet poster
 
Posts: 19
Default Change a specific code to generic in VB macro

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




"Sue" wrote:

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?

--
Sue

  #3   Report Post  
Posted to microsoft.public.excel.misc
gt gt is offline
external usenet poster
 
Posts: 19
Default Change a specific code to generic in VB macro

ooops - one slight change :

LastRow = Range("BE65536").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



"gt" wrote:

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




"Sue" wrote:

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?

--
Sue

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
code to reassign a macro to a toolbar button because of path change Almagg via OfficeKB.com Excel Discussion (Misc queries) 0 April 27th 07 06:42 PM
Generic reference in a Macro Harry's GMail World Excel Discussion (Misc queries) 2 April 17th 07 11:07 PM
Use a code to populate a cell with a specific value braveT Excel Worksheet Functions 5 April 13th 07 10:02 PM
how do i change or make this macro??? pictures and code included dispelthemyth Charts and Charting in Excel 0 March 17th 06 01:02 AM
Creation of a Generic Macro Sondra Excel Worksheet Functions 1 September 13th 05 10:40 PM


All times are GMT +1. The time now is 09:37 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"