+ Reply to Thread
Results 1 to 7 of 7

Find Last Column

  1. #1
    Registered User
    Join Date
    01-09-2020
    Location
    Cleveland, Ohio
    MS-Off Ver
    Office 16
    Posts
    4

    Find Last Column

    Hey Everybody,

    Trying to design a unique application. I'm pretty new to the VBA world. I know how to do somethings but I'm no seasoned pro.

    What I'm trying to do is kind of like a checkbook register but only vertical instead of horizontal. With each entry from my userform, I need it to fill in the next empty column to the right.

    Any help would be great appreciated. Thanks in advance.

  2. #2
    Forum Contributor
    Join Date
    10-30-2019
    Location
    Bistrita, Romania
    MS-Off Ver
    2019; 365
    Posts
    231

    Re: Find Last Column

    You could use the following snippet in your code:
    Please Login or Register  to view this content.
    To show your appreciation
    Click ★ Add reputation!

  3. #3
    Registered User
    Join Date
    01-09-2020
    Location
    Cleveland, Ohio
    MS-Off Ver
    Office 16
    Posts
    4

    Re: Find Last Column

    I'm trying to adapt it to this code for rows. How do I do the same thing but for columns?


    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,259

    Re: Find Last Column

    Hello Myke_Griffin,

    Using Mrrrr's suggestion, your code would look like this to append the data in the last row starting with next available column.
    Please Login or Register  to view this content.
    Last edited by Leith Ross; 01-10-2020 at 02:43 AM.
    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!)

  5. #5
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MSO Home and Business 2024
    Posts
    7,523

    Re: Find Last Column

    vertical instead of horizontal. With each entry from my userform, I need it to fill in the next empty column to the right.
    Reading this, this is my understanding of the question.

    Please Login or Register  to view this content.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  6. #6
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,719

    Re: Find Last Column

    Please Login or Register  to view this content.
    Another solution, for all Columns, could be
    Please Login or Register  to view this content.
    If Row 15 would be the last used row, you would use Cells(lr, 2) instead of Range("B15")

    For values
    Please Login or Register  to view this content.
    If your last used column would be column J, the result of the above would be 10 (=Column J)
    If you would want to refer to Cell K1, you would use Cells(1, 11) '1 for Row1 and 11 for ColumnK

    You can also use
    Please Login or Register  to view this content.
    but that would find the last used column for the first row only.

    If there are formulas included
    Please Login or Register  to view this content.
    From Post #3:
    If "LastRow" would be B10, then
    Offset(1, 0) would be B11
    Offset(1, 1) would be C11
    Offset(1, 2) would be D11
    Offset(1, 3) would be E11
    etc etc
    Offsets go by (Rows offset, Columns offset)
    Last edited by jolivanes; 01-10-2020 at 03:11 AM.

  7. #7
    Registered User
    Join Date
    01-09-2020
    Location
    Cleveland, Ohio
    MS-Off Ver
    Office 16
    Posts
    4

    Re: Find Last Column

    Quote Originally Posted by bakerman2 View Post
    Reading this, this is my understanding of the question.

    Please Login or Register  to view this content.
    This code works. I just have to modify it a little to the specific application. Thank you so much.

    Quick question. A little off topic. My apologies offered.

    Is it possible to have csv format on one sheet in a workbook and have the standard xls form in another sheet within the same workbook?
    Last edited by Myke_Griffin; 01-10-2020 at 08:37 AM.

+ 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. Find keyword in column B and print vaue of column E to column G not working
    By moorea21 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 05-30-2017, 04:58 AM
  2. Replies: 2
    Last Post: 05-23-2017, 08:28 AM
  3. Loop through column to find EID then find date and paste corresponding data
    By CieloSalas in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-01-2017, 06:33 PM
  4. Replies: 3
    Last Post: 11-25-2014, 06:08 AM
  5. Replies: 3
    Last Post: 05-28-2014, 12:01 PM
  6. Replies: 2
    Last Post: 04-26-2013, 01:16 PM
  7. Range.Find to find column and place value in next available cell in one line
    By davegugg in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-02-2011, 10:41 AM

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