修改程序,根据部分字段,来隐藏固定列,可能含有特殊字符
对固定含有某字符的列,进行隐藏,谢了一个简单的程序,但是运用到工作中生成的文件无效,模拟的文件,可以用,请教下,如何修改,程序,谢谢。含有字段的 rev_raised,进行隐藏Sub hide()
Dim rows, cols As Integer
'batch all sheets in this workbook
For Each sh In ThisWorkbook.Sheets
If sh.Name <> "content" And sh.Name <> "summary" Then 'read all sheets except the two sheets
With sh
.Unprotect
rows = ..End(xlUp).Row 'get row number
cols = ..End(xlToLeft).Column 'get column number
'hide
Key = Array("rev_raisedDate_", "rev_raisedDay_")
For j = 1 To cols
Set rngexp = CreateObject("VBScript.RegExp")
With rngexp
.Global = True
.Pattern = "^+$"
End With
'.Cells(4, j) = rngexp.Replace(.Cells(4, j).Value, "")
'.Cells(4, j).Value = Application.Clean(.Cells(4, j).Value)
For k = 0 To 1
Set Rng = .Cells(4, j).Find(what:=Key(k), lookat:=xlWhole)
If Not Rng Is Nothing Then .Columns(j).Hidden = True
Next k
'If Trim(.Cells(1, j).Value) = "a1" Then .Columns(j).Hidden = True
'If InStr(Trim(.Cells(1, j)), "_date") > 0 Then .Columns(j).Hidden = True
'If Right(Trim(.Cells(1, j)), 4) = "date3" Then .Columns(j).Hidden = True
'If Find("_vsdate_dddd", .Cells(1, j), 1) > 0 Then .Columns(j).Hidden = True
Next j
'show all columns
'For j = 1 To cols
'.Columns(j).Hidden = False
' Next j
End With
End If
Next sh
End Sub
复制代码
"Date"&vbcrlf &""
"Days" &vbcrlf & ""
页:
[1]