How to select first empty cell in column F starting from row 1?

How to select first empty cell in column F starting from row 1?

Asked on October 27, 2018 in VBA.
Add Comment


  • 3 Answer(s)

    Here is the solution for selecting the first blank cell in a given column,

    Try this code:

    Public Sub SelectFirstBlankCell()
        Dim sourceCol As Integer, rowCount As Integer, currentRow As Integer
        Dim currentRowValue As String
     
        sourceCol = 6 'column F has a value of 6
        rowCount = Cells(Rows.Count, sourceCol).End(xlUp).Row
     
          'for every row, find the first blank cell and select it
        For currentRow = 1 To rowCount
            currentRowValue = Cells(currentRow, sourceCol).Value
            If IsEmpty(currentRowValue) Or currentRowValue = "" Then
                Cells(currentRow, sourceCol).Select
            End If
        Next
    End Sub
    
    Answered on October 27, 2018.
    Add Comment

    Take the First blank cell in a column and then:

    NextFree = Range("D2:D" & Rows.Count).Cells.SpecialCells(xlCellTypeBlanks).Row
    Range("D" & NextFree).Select
    

    NextFree use this name,so we could use whatever if we wanted.

    Answered on October 27, 2018.
    Add Comment

    Try this code, This will be helpful:

    Public Sub SelectFirstBlankCell()
        Dim sourceCol As Integer, rowCount As Integer, currentRow As Integer
        Dim currentRowValue As String
     
        sourceCol = 6 'column F has a value of 6
        rowCount = Cells(Rows.Count, sourceCol).End(xlUp).Row
     
          'for every row, find the first blank cell and select it
        For currentRow = 1 To rowCount
            currentRowValue = Cells(currentRow, sourceCol).Value
            If IsEmpty(currentRowValue) Or currentRowValue = "" Then
                Cells(currentRow, sourceCol).Select
                Exit For 'This is missing...
            End If
        Next
    End Sub
    
    Answered on October 27, 2018.
    Add Comment


  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.