Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vba 如果值小于另一个单元格值,则清除Excel单元格_Vba_Excel - Fatal编程技术网

Vba 如果值小于另一个单元格值,则清除Excel单元格

Vba 如果值小于另一个单元格值,则清除Excel单元格,vba,excel,Vba,Excel,我希望有人能帮忙,我需要清除单元格,当值小于另一个单元格中的值时。我确实使用了条件格式,但这会将计算进一步打乱到工作表中 我使用了一个指南,当我将固定整数输入到模块中时,我能够删除单元格,但我不确定如何调整它以引用单元格而不是固定数字 多谢各位 Ed我相信这就是您在下面查找的内容,它将从单元格B1中获取一个值,并与a列中的值进行比较,如果值小于B1中的值,它将清除该单元格的内容: Sub ClearLowerThan() Dim c As Range, Rng As Range

我希望有人能帮忙,我需要清除单元格,当值小于另一个单元格中的值时。我确实使用了条件格式,但这会将计算进一步打乱到工作表中

我使用了一个指南,当我将固定整数输入到模块中时,我能够删除单元格,但我不确定如何调整它以引用单元格而不是固定数字

多谢各位


Ed

我相信这就是您在下面查找的内容,它将从单元格B1中获取一个值,并与a列中的值进行比较,如果值小于B1中的值,它将清除该单元格的内容:

Sub ClearLowerThan()
    Dim c As Range, Rng As Range
    Dim LastRow As Long        
    Dim ws As Worksheet: Set ws = Sheets("Sheet1")
    'declare you worksheet, amend as required
    LastRow = ws.Cells(ws.Rows.Count, "A").End(xlUp).Row
    'get the last row with data on Column A

    CompareVal = ws.Range("B1").Value
    'get the value to compare against, in this case from cell B1

    Set Rng = ws.Range("A1:A" & LastRow)
    'set the range to compare against the value from B1

    For Each c In Rng 'for each cell in the given range
        If c.Value < CompareVal Then c.ClearContents
        'if value of cell is less than the value to compare against, clear the cell contents.
    Next
End Sub
Sub-ClearLowerThan()
尺寸c作为范围,Rng作为范围
最后一排一样长
将ws标注为工作表:设置ws=工作表(“工作表1”)
'声明您的工作表,根据需要进行修改
LastRow=ws.Cells(ws.Rows.Count,“A”).End(xlUp).Row
'获取列A上包含数据的最后一行
CompareVal=ws.范围(“B1”).值
'从单元格B1中获取要比较的值
设置Rng=ws.Range(“A1:A”和LastRow)
'设置要与B1中的值进行比较的范围
对于给定范围内每个单元格的每个c(单位:Rng
如果c.值
请详细说明一下,您的问题描述很简单,您需要实际清除一个单元格,还是让值=零或空白?如果只是空白,为什么不使用公式<代码>=如果(B2>100,“,”其他内容”)同样,请附上您当前用于尝试解决此问题的资料。如果您尝试过各种方法,也可以添加这些方法的简要说明,这样您就不会得到重复的建议。