Macro fill-down

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

JeffSchwartz

Thread Starter
Joined
Jan 31, 2013
Messages
56
Tech Support Guy System Info Utility version 1.0.0.2
OS Version: Microsoft Windows 7 Home Premium, Service Pack 1, 64 bit
Processor: Intel(R) Core(TM) i3-2310M CPU @ 2.10GHz, Intel64 Family 6 Model 42 Stepping 7
Processor Count: 4
RAM: 6091 Mb
Graphics Card: Intel(R) HD Graphics Family, -1274 Mb
Hard Drives: C: Total - 455060 MB, Free - 394130 MB; D: Total - 21574 MB, Free - 2263 MB;
Motherboard: Hewlett-Packard, 1650
Antivirus: Norton Internet Security, Disabled

I am working on developing a series of macros in Excel 2010. I need to select a region down to the bottom of the file (where there is text in other fields) in order to fill-down data for eight adjacent columns. If I select a section by hand as a record the macro it will only select to that end line whenever the marco is run. How do I select a region down to the last line that contains data in other fields?
 
Joined
Jun 29, 2012
Messages
518
can you use this in your macro to identify the last row that contains data?
TheLastRow = ActiveCell.SpecialCells(xlCellTypeLastCell).Row
 

JeffSchwartz

Thread Starter
Joined
Jan 31, 2013
Messages
56
can you use this in your macro to identify the last row that contains data?
TheLastRow = ActiveCell.SpecialCells(xlCellTypeLastCell).Row
That might work, but I'm not sure how to include it in a SELECT command. For instance, I would want to select a region of columns A-G, rows 3- (last row). Any ideas?
 

JeffSchwartz

Thread Starter
Joined
Jan 31, 2013
Messages
56
In my initial post, I meant to say- If I select a section by hand as record the macro it will only select to that end line whenever the marco is run. [Other files that I run this macro on will have more or less rows of data.] How do I select a region down to the last line that contains data in other fields?
 
Joined
Jun 29, 2012
Messages
518
Jeff,
the macro TheLastRow will identify the last row that contains data, what col does not matter.
one way you could select your range would be
sub ChooseRange()
TheLastRow = ActiveCell.SpecialCells(xlCellTypeLastCell).Row
Range("A1:G" & TheLastRow).Select
End Sub
Experiment.
Add data to any cell in columns A-G to add some rows that have data in them, and it will find and include the last row with data in your selected range.
 

JeffSchwartz

Thread Starter
Joined
Jan 31, 2013
Messages
56
I tried this and it works, although it selects nine rows more than the rows containing data in columns H through (whatever). I suppose I could figure out a way to select and delete those last nine rows.
 
Joined
Jun 29, 2012
Messages
518
if is selecting rows further rhan you believe there should be data, then delete those extra rows. there is sometjing there that the command is finding. delwting will not hurt if nothing should be there anyway.
 

Keebellah

Hans
Trusted Advisor
Joined
Mar 27, 2008
Messages
6,612
sometimes when you delete cell contents it still considers those cells to be the last filled.

Sometime after saving, closing and reopening the file it will reset that.
The command 20_2_Many uses to determine the last row is the one I meant in the other post about column J
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Members online

Top