简体   繁体   中英

Select from ActiveCell to first cell in column. Data in column includes blanks

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM