+ Reply to Thread
Results 1 to 4 of 4

Macro to start autofill from the last cell

Hybrid View

  1. #1
    Registered User
    Join Date
    08-13-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    87

    Macro to start autofill from the last cell

    Hello,
    I been trying to get this code to work, but I am not able to define the last cell from where autofill should start, Could someone help me on this?

    Dim a As Long
        For a = 25 To 72
            If Range("A" & a).Value = "" And Range("B" & a) <> "" Then
                'what to do if cell is empty
                Range("A" & a) = "AK"
                   Dim lastrow As Long
        lastrow = Worksheets("sheet1").Range("B65536").End(xlUp).Row
        With Worksheets("Sheet1").Range("A25")
            .autofill Destination:=Range("A25:A" & lastrow&) "WHAT CHANGES SHOULD I MAKE HERE SO THAT INSTEAD OF CELL A25 IT WILL TAKE THE CELL VALUE OF RANGE("A" & a)"
        End With
                Exit For
            End If
        Next a

    Thanks,
    Aadesh Gandhi

  2. #2
    Valued Forum Contributor fredlo2010's Avatar
    Join Date
    07-04-2012
    Location
    Miami, United States
    MS-Off Ver
    Excel 365
    Posts
    762

    Re: Macro to start autofill from the last cell

    Hello,

    Do you have a copy of the workbook? Why are you using auto fill? for a formula?

    Thanks

  3. #3
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Macro to start autofill from the last cell

    Wouldn't it be:

            .autofill Destination:=Range("A" & a & ":A" & lastrow)
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  4. #4
    Registered User
    Join Date
    08-13-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    87

    Re: Macro to start autofill from the last cell

    Quote Originally Posted by JBeaucaire View Post
    Wouldn't it be:

            .autofill Destination:=Range("A" & a & ":A" & lastrow)
    Yes Sir! It what it needs to be, thank you for the response.



    R/
    Aadesh Gandhi

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1