在列中查找最后一个非空白单元格,然后在该行的后4列中选择该单元格和单元格。 [英] Find Last non blank cell in a column and select that cell and cells in next 4 columns of that row.

查看:89
本文介绍了在列中查找最后一个非空白单元格,然后在该行的后4列中选择该单元格和单元格。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用一个按钮来查找范围的最后一个非空单元格,并选择该单元格和它旁边的4列中的单元格来删除这些值。

I want to use a button to look for the last Non-blank cell of a Range and to select that cell and the cells in the 4 columns next to it to delete those values.

示例:如果"H1:H260"的最后一个非空白单元格为在第25行,我需要选择单元格"H25:L25"。并删除这些值。

Example: If the Last non-blank cell of "H1:H260" is on row 25 then I need to select cells "H25:L25" and delete those values.

我使用这个公式来查找第一个"空白"。范围的单元格,但我无法弄清楚如何让按钮选择具有信息的下一个单元格。以及该单元格旁边的4列中的单元格以删除该信息。: 

I use this formula for finding the first "Blank" cell of a Range but I can't figure out how to get the button to select the next cell up that does have info. and the cells in the 4 columns beside that cell to delete that info.: 

Sub Find_First_Blank_Cell()

    x =单元格(Rows.Count,"H")。End(xlUp).Row

    nar =范围("H1:H260"& x).Find(")。行

   单元格(nar,"H")。选择

结束子

Sub Find_First_Blank_Cell()
    x = Cells(Rows.Count, "H").End(xlUp).Row
    nar = Range("H1:H260" & x).Find("").Row
    Cells(nar, "H").Select
End Sub

请帮助初学者,

谢谢

推荐答案

您好
FoosMaster,

请参考下面提到的示例。基于此,您可以尝试开发自己的代码。

please refer the example mentioned below. based on that you can try to develop your own code.

如上所述我创建了1个按钮,在按钮的点击事件中我写了代码。

as you mentioned above I create 1 button and on the click event of button I wrote the code.

例如,我在这里使用Range(A1:A10)。

For example here I am using Range (A1:A10).

所以当你点击按钮时,它会找到最后一个在范围内使用过的单元格(A1:A10) 。然后选择同一行中的那个和下四个单元格。

so when you click on the button it will find the last used cell in range (A1:A10). then select that and next four cells in the same row.

Private Sub CommandButton1_Click()
Dim WS As Worksheet
Dim LastCell As String
LastCell = Range("A1:A10").SpecialCells(xlCellTypeLastCell).Row
ActiveSheet.Range("A" & LastCell & ": E" & LastCell).Select
End Sub

输出:

你可以看到最后使用的单元格是A9。因此它选择范围A9:E9。

you can see that last used cell is A9. so it select the range A9:E9.

问候

Deepak


这篇关于在列中查找最后一个非空白单元格,然后在该行的后4列中选择该单元格和单元格。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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