从第 1 行开始选择 F 列中的第一个空单元格.(不使用 offset ) [英] Select first empty cell in column F starting from row 1. (without using offset )

查看:14
本文介绍了从第 1 行开始选择 F 列中的第一个空单元格.(不使用 offset )的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个令我非常困惑的查询.因为我已经找了很多次了,但我总是找到与查找最后使用的或第一个非空单元格相关的代码.在下面的代码中尝试过.diff 代码已被偶数"一词分隔

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 

Sub LastCellBeforeBlankInColumn()

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

End Sub

查找列中最后使用的单元格:

Find the very last used cell in a Column:

Sub LastCellInColumn()

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

End Sub

找到一行空白前的最后一个单元格:

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

Sub LastCellBeforeBlankInRow()

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

End Sub

查找一行中最后使用的单元格:

Find the very last used cell in a Row:

Sub LastCellInRow()

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

End Sub

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

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

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

推荐答案

如果您要做的只是选择给定列中的第一个空白单元格,您可以尝试一下:

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

代码:

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

选择前 - 要选择的第一个空白单元格:

选择后:

这篇关于从第 1 行开始选择 F 列中的第一个空单元格.(不使用 offset )的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆