循环一系列空白(白色)单元格,直到找到一个数字 [英] Loop a range of blank (white) cells until a number is found

查看:81
本文介绍了循环一系列空白(白色)单元格,直到找到一个数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,


我不是开发人员,但需要Excel 2013中的公式/宏的帮助才能遍历一系列空白单元格,直到找到一个数字并且如果是,请停止循环并在特定单元格中填充该数字。 请记住,我不是一个
的开发人员,需要一步一步的细节......循环通过单元格范围W16:BN16,在该范围内的第一个单元格中,有一个数字,任意数字,停止循环并在单元格J16中输入该数字。 


LDVS

解决方案

首先,选择文件>选项。


在左侧导航窗格中选择自定义功能区。


确保在Main列表中选中Developer的复选框右侧的选项卡。


单击"确定"。


您现在在功能区中有一个"开发人员"选项卡。激活它。


单击Visual Basic以激活Visual Basic编辑器(如果您更喜欢键盘快捷键,也可以按Alt + F11)。


选择插入>用于创建新代码模块的模块。


将以下宏复制到新模块中:

 Sub LoopUntilNotBlank( )
Dim cel As Range
For Each cel In Range(" W16:BN16")
if cel.Value<> ""和IsNumeric(cel.Value)然后
范围("J16")。值= cel.Value
退出
结束如果
下一个cel
结束Sub

关闭Visual Basic编辑器。


单击功能区的"开发人员"选项卡上的"宏"。


选择LoopUntilNotBlank,然后单击"运行"。


确保将工作簿保存为启用宏的Excel工作簿(.xlsm),并在打开工作簿时允许使用宏。


Hello,

I am not a developer but need assistance with a formula/macro in Excel 2013 to loop through a range of blank cells until a number is found and when it is, stop looping and populate that number in a specific cell.  Please keep in mind I am not a developer and will need step by step details...loop through cell range W16:BN16, at the first cell in that range that has a number, any number, stop the loop and enter that number in cell J16. 

LDVS

解决方案

First, select File > Options.

Select Customize Ribbon in the navigation pane on the left.

Make sure that the check box for Developer is ticked in the list of Main Tabs on the right.

Click OK.

You now have a Developer tab in the ribbon. Activate it.

Click Visual Basic to activate the Visual Basic Editor (you can also press Alt+F11 if you prefer keyboard shortcuts).

Select Insert > Module to create a new code module.

Copy the following macro into the new module:

Sub LoopUntilNotBlank()
    Dim cel As Range
    For Each cel In Range("W16:BN16")
        If cel.Value <> "" And IsNumeric(cel.Value) Then
            Range("J16").Value = cel.Value
            Exit For
        End If
    Next cel
End Sub

Close the Visual Basic Editor.

Click Macros on the Developer tab of the ribbon.

Select LoopUntilNotBlank, then click Run.

Make sure that you save the workbook as a macro-enabled Excel workbook (.xlsm), and that you allow macros when you open the workbook.


这篇关于循环一系列空白(白色)单元格,直到找到一个数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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