Results 1 to 6 of 6

Using .end(xlToLeft) and tables

Threaded View

  1. #1
    Registered User
    Join Date
    11-05-2010
    Location
    Over, There
    MS-Off Ver
    Excel 2016
    Posts
    44

    Using .end(xlToLeft) and tables

    I have a table that is populated with data and I am trying to find the last cell that has data in it. When I try to search I either can't get the last column or I only get the last column. Here's the code:

    Range(Split(ThisWorkbook.Worksheets(1).Columns(Range(Range("A1").End(xlToRight).Offset(1, 0).Address).End(xlToLeft).Column).Address, ":")(0) & "1:" & Split(ThisWorkbook.Worksheets(1).Columns(Range(Range("A1").End(xlToRight).Offset(1, 0).Address).End(xlToLeft).Column).Address, ":")(0) & Range(ThisWorkbook.PintsTotLoc).Row + 2).Select
    That code will find the first populated cell with data in it, but if the table is fully filled out from left to right the furthest right column won't get picked up as the last populated cell. So I tried:

    Range(Split(ThisWorkbook.Worksheets(1).Columns(Range(Range("A1").End(xlToRight).Offset(1, 1).Address).End(xlToLeft).Column).Address, ":")(0) & "1:" & Split(ThisWorkbook.Worksheets(1).Columns(Range(Range("A1").End(xlToRight).Offset(1, 1).Address).End(xlToLeft).Column).Address, ":")(0) & Range(ThisWorkbook.PintsTotLoc).Row + 2).Select
    Which will only get the furthest right column in the table if its blank or not. I'm assuming that the code is thinking that a table is "data" and shows that cell as populated. How can I search the table from right to left?

    Note: I can't search from left to right because there may be some blank columns within the table.
    Last edited by Demon4231; 01-04-2012 at 05:21 AM.

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