Results 1 to 8 of 8

Thread: Autofilling in VBA through the last row

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Junior Member
    Join Date
    Mar 2013
    Posts
    4
    Rep Power
    0

    Autofilling in VBA through the last row

    I posted a similar question here VBA Autofill hanging - quick debug but I've found on that forum that once your question is buried you usually don't get a response. (Otherwise pretty good forum)

    I would appreciate your help. In VBA macro code, when I want to extend a formula down through a column, I use something like this:
    Code:
    Range("H2").Select
            Selection.AutoFill Destination:=Range("H2:H" & Range("A2").End(xlDown).Row), Type:=xlFillDefault
    This works fine if there is data on at least the next row (row 3 in this example). However, it gets buggy and strange when there is only data on the row the code is working on. That is, in this example, if there is only the header/column label row in row 1 and one row of data in row 2, then this code doesn't work well and seems to hang.

    What is the best way to extend formulas down through however many rows there are and not run into problems if there is only one data row?

    Thanks!

    (I was brought here via a link in Rick Rothstein's signature on a post he gave a great answer too (much better than mine!))
    Last edited by jardenp; 03-29-2013 at 02:08 AM. Reason: added

Similar Threads

  1. Highlight Current Row in Excel (VBA)
    By Admin in forum Excel and VBA Tips and Tricks
    Replies: 16
    Last Post: 07-31-2013, 06:46 AM
  2. VBA code to move row to new spreadsheet
    By cdurfey in forum Excel Help
    Replies: 6
    Last Post: 06-10-2013, 10:38 PM
  3. Replies: 7
    Last Post: 05-17-2013, 10:38 PM
  4. Copy Table Range Till Last Row Using VBA
    By ivandgreat in forum Excel Help
    Replies: 2
    Last Post: 05-09-2013, 05:41 PM
  5. Vba Code to find value and paste on certain row
    By jwitte in forum Excel Help
    Replies: 3
    Last Post: 11-28-2012, 08:52 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •