Results 1 to 3 of 3

Thread: Finding Last column
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    Board Regular
    Join Date
    Oct 2017
    Posts
    349
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default Finding Last column

    Code:
    Private Sub Constant_demo_Click()
    Dim numbers() As Integer
    Dim i As Integer
    Dim Size As Integer
    Size=WorksheetFunction.CountA(Worksheets(1).Columns(1))
    ReDim numbers(Size)
    For i = 1 To Size
        numbers(i) = Cells(i, 1).Value
    Next i
    MsgBox numbers(Size)
    End Sub
    Looking for alternative way to find last row in column

  2. #2
    MrExcel MVP Rick Rothstein's Avatar
    Join Date
    Apr 2011
    Location
    New Jersey, USA
    Posts
    35,248
    Post Thanks / Like
    Mentioned
    92 Post(s)
    Tagged
    33 Thread(s)

    Default Re: Finding Last column

    LastCol = Cells(Rows.Count, "A").End(xlUp).Row
    Rick's "mini" blog... http://www.excelfox.com/forum/f22/
    .
    Want to post a small screen shot? See Part B here.

  3. #3
    MrExcel MVP AlphaFrog's Avatar
    Join Date
    Sep 2009
    Posts
    16,087
    Post Thanks / Like
    Mentioned
    16 Post(s)
    Tagged
    7 Thread(s)

    Default Re: Finding Last column

    Two methods.

    Code:
        Size = Worksheets(1).Columns(1).Find("*", , , , 1, 2).Row
        
        Size = Worksheets(1).Cells(Rows.Count, 1).End(xlUp).Row
    Paste your Excel data to the forum...
    MrExcel HTML Maker or Excel Jeanie

    How to post your vba code
    [CODE]your VBA code here[/CODE]
    The # button in the forum's editor will apply CODE tags around your selected text.

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •