Select from ActiveCell to first cell in column. Da

2019-08-21 20:41发布

I have a sheet with data that contains no blanks in the first column. Subsequent columns contain blanks. I need to set individual columns to several range variables. The problem I am having is that using "xlUp" stops at the first blank.

Any suggestions on what to do?

Here is some example code. I'm commenting out the lines that I have been using to try and get this to work (the copy line was so I could paste into a blank sheet to see what was being selected.)

Sub Test_Subject_Ranges()
    Sheets("Current Day Raw").Select
    ActiveSheet.Range("A1").Select    
    Range("A1").End(xlDown).Select                 'Takes me to the bottom of my data.
    ActiveCell.Offset(0, 11).Select                'Takes me to the column I need here.
==> Range(ActiveCell, ActiveCell.End(xlUp)).Select 'The problem line.
    Dim CurrentDayPALessonsPassed As Range
    Set CurrentDayPALessonsPassed = Selection
    Selection.Copy
End Sub

标签: excel vba
1条回答
\"骚年 ilove
2楼-- · 2019-08-21 20:55

This will select all cells from the ActiveCell to the top of the column in which it resides:

Sub ToTheTop()
    Range(ActiveCell, ActiveCell.EntireColumn.Cells(1)).Select
End Sub
查看更多
登录 后发表回答