Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Select first empty cell in column F starting from row 1. (without using offset )

Tags:

excel

vba

This is one query that I am really confused with. Coz I have looked for this so many times but I always find the codes related to finding the last used or first non empty cell. Tried at below codes. diff codes have been separated by the word "even"

iRow = Worksheets("Sheet1").Cells(Rows.Count,1).End(XlUp).Row  

even

Sub LastCellBeforeBlankInColumn()  Range("A1").End(xldown).Select  End Sub 

even

Find the very last used cell in a Column:

Sub LastCellInColumn()  Range("A65536").End(xlup).Select  End Sub 

even

Find the last cell, before a blank in a Row:

Sub LastCellBeforeBlankInRow()  Range("A1").End(xlToRight).Select  End Sub 

even

Find the very last used cell in a Row:

Sub LastCellInRow()  Range("IV1").End(xlToLeft).Select  End Sub 

even

Worksheets("Sheet1").Range("A1").End(xlDown).Row + 1 

even

LastRow = Range("A" & Rows.Count).End(xlUp).Row + 1 Sheets("SheetName").Range("A" & LastRow).Paste 

even

Dim FirstBlankCell as Range Set FirstBlankCell=Range("A" & rows.Count).end(xlup).offset(1,0) FirstBlankCell.Activate  'Find the last used row in a Column: column A in this example Dim LastRow As Long Dim NextRow As Long With ActiveSheet     LastRow = .Cells(.Rows.Count, "F").End(xlUp).Row End With NextRow = LastRow + 1 
like image 519
Nishant Avatar asked Feb 19 '13 12:02

Nishant


People also ask

How do I find the first empty cell in a column in Excel?

Excel doesn't have a built-in formula to find the first blank cell in a range. However, there is the ISBLANK function, which tests a cell, and returns a Boolean value according to its content. The function returns TRUE if cell is blank, FALSE otherwise.

How do I select the last empty cell in Excel VBA?

SpecialCells(xlCellTypeLastCell) The SpecialCells method does the same thing as pressing the Ctrl+End keyboard shortcut and selects the last used cell on the sheet.

How do you go to the next blank row in Excel?

If you need to quickly jump to the next blank cell in a row, the Go To feature can help. To do this, press the F5 key, type in the cell address of the first cell in the row, and then press the Enter key. Then, press the Ctrl+Right arrow key on your keyboard. This will take you to the next blank cell in the row.


2 Answers

If all you're trying to do is select the first blank cell in a given column, you can give this a try:

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 

Before Selection - first blank cell to select:

enter image description here

After Selection:

enter image description here

like image 57
StoriKnow Avatar answered Oct 13 '22 13:10

StoriKnow


If all you're trying to do is select the first blank cell in a given column, you can give this a try:

Range("A1").End(xlDown).Offset(1, 0).Select 

If you're using it relative to a column you've selected this works:

Selection.End(xlDown).Offset(1, 0).Select 
like image 44
Chandan B Avatar answered Oct 13 '22 14:10

Chandan B