+ Reply to Thread
Results 1 to 10 of 10

Writing code to fill a column

  1. #1
    Forum Contributor
    Join Date
    08-08-2011
    Location
    Jacksonville, Florida
    MS-Off Ver
    Excel 2007
    Posts
    123

    Writing code to fill a column

    Can someone tell me how to write the code below to fill the cells with "IORY"?

    Also, when I recorded the macro I use commands like shift + end + down arrow. If I have a worksheet that has a different amount of data that exceeds A145 will that macro use the same commands or use the same range? If this is the case how can you write a macro that is flexible?





    Please Login or Register  to view this content.
    Last edited by dalewms2; 08-31-2011 at 02:15 PM.

  2. #2
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Writing code to fill a column

    dalewms2,

    Something like this?
    Please Login or Register  to view this content.


    Hope that helps,
    ~tigeravatar

  3. #3
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Writing code to fill a column

    Let's back up a step: Exactly what are you trying to do?
    Entia non sunt multiplicanda sine necessitate

  4. #4
    Forum Contributor
    Join Date
    08-08-2011
    Location
    Jacksonville, Florida
    MS-Off Ver
    Excel 2007
    Posts
    123

    Re: Writing code to fill a column

    I am new at VBA and without re-writing the entire code I am trying to fill these cells with "IORY". thanks

  5. #5
    Forum Contributor
    Join Date
    08-08-2011
    Location
    Jacksonville, Florida
    MS-Off Ver
    Excel 2007
    Posts
    123

    Re: Writing code to fill a column

    thank you. Can you look at the 2nd part of my question?

  6. #6
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Writing code to fill a column

    range.End(xlDown) mimics using shift + end + down arrow. I'm with shg on this one, what exactly are you asking for?

  7. #7
    Forum Contributor
    Join Date
    08-08-2011
    Location
    Jacksonville, Florida
    MS-Off Ver
    Excel 2007
    Posts
    123

    Re: Writing code to fill a column

    I am asking because this is my first macro with this file extraction. The next time the file may have a greater amount of rows. I just want to know when the macro says: [Range("A2:A145") and the next worksheet has the range A2:A175 , the macro will include the entire range. If not I need to go back and edit the macro. thanks

  8. #8
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Writing code to fill a column

    Yes, you will need to rewrite the entire macro. It will always use the range A2:A145. Your entire macro (as shown in your post) can be replaced by the single line that Tiger gave you. I hope that helps.
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  9. #9
    Forum Contributor
    Join Date
    08-08-2011
    Location
    Jacksonville, Florida
    MS-Off Ver
    Excel 2007
    Posts
    123

    Re: Writing code to fill a column

    When I use range.End(xlDown) do I need to specify a column? If so, please give me an example.

  10. #10
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Writing code to fill a column

    It will use the move down from whatever range is specified. In tiger's example, (Range("A2") it would be column A.

+ 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