Devin McGhee
Devin McGhee

Reputation: 3

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

Upvotes: 0

Views: 9321

Answers (1)

Gary's Student
Gary's Student

Reputation: 96773

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

Upvotes: 1

Related Questions