+ Reply to Thread
Results 1 to 9 of 9

Select last cell with the data in the column/range of cells

  1. #1
    Registered User
    Join Date
    08-12-2014
    Location
    London
    MS-Off Ver
    2007
    Posts
    51

    Select last cell with the data in the column/range of cells

    Hi,
    I have used the following macro: http://www.excel-easy.com/vba/exampl...ast-entry.html what does works however this macro still select 'empty' cells that contains formula showing "" (blank) if false.
    How can I programe this to select only 'visible' datas?

    Test file attached: starting with A1 going down I wish to select only numbers we can actually see, not the formulas cells underneath.
    I will have to change the range a lot as weel (instead having A1 I may need to have E1:N40 etc).
    Attached Files Attached Files

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Select last cell with the data in the column/range of cells

    Try this...
    Please Login or Register  to view this content.
    For E1:N? it may look like...
    Please Login or Register  to view this content.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Registered User
    Join Date
    08-12-2014
    Location
    London
    MS-Off Ver
    2007
    Posts
    51

    Re: Select last cell with the data in the column/range of cells

    Hi,

    Thank you for this, this does work as I needed!
    Greg
    Last edited by PENGUIN88; 10-02-2014 at 11:02 AM.

  4. #4
    Registered User
    Join Date
    08-12-2014
    Location
    London
    MS-Off Ver
    2007
    Posts
    51

    Re: Select last cell with the data in the column/range of cells

    Hi,
    Sorry to be a pain but this does the same thing actually... It still does select the cels with formulas that shows ""/blank/null.

    I have an piece of code that finds me the first empty cell in the column and this is working for me but I do not know how to put this together so it does select the range of the cells - as stated above: E1:N60 for an example.

    Here is the code I have and this finds next empty cell and ignores formulas that are null/blank/"":

    Wb1.Sheets(6).Columns("E").Find(vbNullString, Cells(Rows.Count, "E")).Select

    Is there the way to modify this code to achieve the task that select all cells in range E1:N60 up to next empty cell in E column?
    You can ignore Wb1.sheets(6) part as I do know how to change this.

  5. #5
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Select last cell with the data in the column/range of cells

    Quote Originally Posted by PENGUIN88 View Post
    select all cells in range E1:N60 up to next empty cell in E column?
    Wb1.Sheets(6).Range("E1:N" & Wb1.Sheets(6).Range("E:E").Find("*", , , , 1, 2).Row).Select

    Or

    Wb1.Sheets(6).Range("E1", Wb1.Sheets(6).Range("E:E").Find("*", , , , 1, 2)).Resize(, 10).Select


    Be sure to qualify the worksheet for both ranges (or cells) references.

  6. #6
    Registered User
    Join Date
    08-12-2014
    Location
    London
    MS-Off Ver
    2007
    Posts
    51

    Re: Select last cell with the data in the column/range of cells

    Hi,
    This still doeas the same?? I'm not sure why now! ;(
    Macro still select cells with formula that shows "" - blank as an result.

    What do you mean by:
    Be sure to qualify the worksheet for both ranges (or cells) references.

    Is this something I need to change in excel settings?!

  7. #7
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Select last cell with the data in the column/range of cells

    Wb1.Sheets(6).Range("E1:N" & Wb1.Sheets(6).Range("E:E").Find("*", , xlValues, , 1, 2).Row).Select

    Or

    Wb1.Sheets(6).Range("E1", Wb1.Sheets(6).Range("E:E").Find("*", , xlValues, , 1, 2)).Resize(, 10).Select




    In your previous example code, you didn't qualify the 2nd cell reference with a worksheet.
    Wb1.Sheets(6).Columns("E").Find(vbNullString, Cells(Rows.Count, "E")).Select

    All cells, columns and, ranges that are not qualified with a worksheet will default to the Active sheet. If you only qualify some and not others, that may cause an error. Your example code should have been

    Wb1.Sheets(6).Columns("E").Find(vbNullString, Wb1.Sheets(6).Cells(Rows.Count, "E")).Select

  8. #8
    Registered User
    Join Date
    08-12-2014
    Location
    London
    MS-Off Ver
    2007
    Posts
    51

    Re: Select last cell with the data in the column/range of cells

    Hi,

    Oh yes I knew about it but sometimes I just forget to add these when I do copy and paste code from form to new form (existing macro) and it did work well so this may be a reason why Cells have not referal Thank you for that.

    Range("E1:M" & Range("E:E").Find("*", , xlValues, , 1, 2).Row).Select <--- This is what I need, thank you!

  9. #9
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Select last cell with the data in the column/range of cells

    You're welcome.

+ 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. Select Range In Column Based On Two Different Cells
    By Regular_Joe in forum Excel Programming / VBA / Macros
    Replies: 22
    Last Post: 05-30-2014, 11:47 AM
  2. [SOLVED] Unlock a range of cells in a column ONLY when the first cell of that column has data.
    By damienchew in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-13-2014, 12:14 AM
  3. Find & select 1st blank cell in a range of formulated column cells
    By jnbroek in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-19-2013, 09:26 AM
  4. [SOLVED] VBA: Select Range of Cells in one Column, Merge, and then proceed to Next Column
    By magasi in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-27-2013, 12:17 PM
  5. Replies: 4
    Last Post: 06-17-2013, 05:21 AM

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