Results 1 to 3 of 3

My macro not selecting enough cells to the right

Threaded View

  1. #1
    Forum Contributor
    Join Date
    11-20-2009
    Location
    Melbourne
    MS-Off Ver
    Excel 365
    Posts
    288

    My macro not selecting enough cells to the right

    The following code is working almost perfectly for what I want. The only problem I am having is that
    the code selects the populated cells from Column 'O' across to Column 'V' inclusive. Can some explain
    why does the code not pick up the remaining 4 populated columns that I need 'W - Z'.
    Thank you all for your advice.

    Private Sub CommandButton18_Click()
    Dim Lastrow As Double
    Dim LastCol As Double
    
    LR = Cells(Rows.Count, "O").End(xlUp).Row
    LastCol = Cells(12, Columns.Count).End(xlToLeft).Column
    ' Make the 12 above for any row you want that has lots of columns of data
    
    Range(Cells(1, 15), Cells(LR, LastCol)).Cut
    Range("B" & Cells.Rows.Count).End(xlUp).Offset(1, 0).Select
    ActiveSheet.Paste
        Application.CutCopyMode = False
    End Sub
    Last edited by coach.32; 03-28-2013 at 08:24 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