如果不喜欢vba [英] If not like vba

查看:42
本文介绍了如果不喜欢vba的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果特定的单元格格式不是每小时格式,我想应用一个条件(删除行)

i wanted to apply a condition (Deleting rows) if a particular cell format is NOT hourly format

我尝试了以下代码,但没有用

I tried the below code but it doesn't work

Sub delete_row()

Dim i As Integer
Dim LR As Long
 LR = Range("A" & Rows.Count).End(xlUp).Row

For i = 1 To LR
If Not Cells(i, 1).Value Like "##:##-##:##" Then
Cells(n, 1).EntireRow.Delete


End If
Next i
End Sub

推荐答案

我会这样做:

Sub DeleteRow()
    Dim i As Integer

    For i = Range("A" & Rows.Count).End(xlUp).Row To 1 Step -1
        If Range("A" & i).NumberFormat = "hh:mm AM/PM" Then   //Update format to suit your needs
            Range("A" & i).EntireRow.Delete
        End If
    Next i
End Sub

从值列的底部开始并向上操作,检查单元格格式并适当删除.

Start at the bottom of the column of values and work upwards, checking for cell format and deleting as appropriate.

这篇关于如果不喜欢vba的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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