+ Reply to Thread
Results 1 to 4 of 4

Excel VBA: changing hard coded column to dynamic range to autofill to last row

  1. #1
    Registered User
    Join Date
    01-03-2014
    Location
    Spain
    MS-Off Ver
    Excel 2010
    Posts
    2

    Excel VBA: changing hard coded column to dynamic range to autofill to last row

    Hello from an unexperienced vba user.. I'm having trouble with the code for autofill to the last row when trying to use named ranges for the column. Everything seems to work fine when I use a hard coding for the column, in this case Column CW, and what I need is to replace this column CW with a named range so that the macro will still work when adding or deleting columns in the worksheet.

    I used the following named ranges:

    First_Date: This is the header cell of one of the columns (in this case AP5)
    Second_Row: This is the range of columns I want to copy the formulas from (AP7:CW7)
    Second_Cell: The cell where I want to start to autofill (AP7)
    Last_Column: This is column CW that I want to use in the code. Autofill would be up to this column and down to the last row.

    After searching in different threads, I came up with the following code that seems to work fine. How can I change column CW to a named range? Or do I need to change the code?

    Please Login or Register  to view this content.
    Can anyone assist me here please?

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Excel VBA: changing hard coded column to dynamic range to autofill to last row

    Hello AishaSanz,

    Welcome to the Forum!

    For best results, you should post your workbook. The code can then be fully tested and debugged. Please include before and after examples of the data along with any notes.
    If your workbook contains sensitive information, please redact it before posting.

    How To Post Your Workbook
    1. At the bottom right of the Reply window, Click the button Go Advanced
    2. At the top of the Your Message Window, in the first row of icons, Click the Paperclip icon.
    3. Click the Add Files button at the top right in the dialog box. This displays the File Manager dialog.
    4. Click the Select Files button at the bottom middle of the dialog.
    5. In the new window Find the file you want to upload, select it, and Click Open.
    6. You will now be back in the File Manager dialog. Click the bottom Middle button Upload File.
    7. Wait until the file has completely uploaded before you exit the File Manager dialog.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    01-03-2014
    Location
    Spain
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: Excel VBA: changing hard coded column to dynamic range to autofill to last row

    Hello Leith Ross, thank you for the tips, which I will surely keep in mind for next time. Someone told me the solution to my coding problem:

    Changing
    Please Login or Register  to view this content.
    To
    Please Login or Register  to view this content.

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Excel VBA: changing hard coded column to dynamic range to autofill to last row

    Hello AishaSanz,

    You're welcome. Thank you for sharing the solution.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 6
    Last Post: 08-04-2013, 11:53 AM
  2. [SOLVED] Convert two dimensional row to column data to a hard-coded array
    By evancharles in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 06-07-2013, 03:15 PM
  3. Link Hard-coded in Excel
    By JoeNK in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-12-2012, 10:59 AM
  4. Autofill using Dynamic Range (Last Column) and Last Row
    By goldenr2 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-05-2011, 11:21 PM
  5. Hard coded number range into a function
    By bigdavediode in forum Excel General
    Replies: 9
    Last Post: 04-10-2009, 12:09 PM

Tags for this Thread

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