1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Macro fill-down

Discussion in 'Business Applications' started by JeffSchwartz, Jan 31, 2013.

Thread Status:
Not open for further replies.
Advertisement
  1. JeffSchwartz

    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?
     
  2. Garf13LD

    Garf13LD

    Joined:
    Apr 17, 2012
    Messages:
    455
    Don't quite get what you mean.
    Pls attach a file to illustrate.
     
  3. 20_2_Many

    20_2_Many

    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
     
  4. JeffSchwartz

    JeffSchwartz Thread Starter

    Joined:
    Jan 31, 2013
    Messages:
    56
    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?
     
  5. JeffSchwartz

    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?
     
  6. 20_2_Many

    20_2_Many

    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.
     
  7. JeffSchwartz

    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.
     
  8. 20_2_Many

    20_2_Many

    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.
     
  9. Keebellah

    Keebellah Trusted Advisor

    Joined:
    Mar 27, 2008
    Messages:
    6,576
    First Name:
    Hans
    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
     
  10. Garf13LD

    Garf13LD

    Joined:
    Apr 17, 2012
    Messages:
    455
    Or you can do a sheet.calculate to "reset" the last row before running the macro.
     
  11. Sponsor

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 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/1087720

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice