1
此代码是一个宏,用于搜索不同工作表中的某些值并删除其列。但是,如果我想删除所有其他列而不是,并且将它们保留在我正在搜索的位置,我该怎么办?删除所有其他列
换句话说,我想让宏做相反的事情吗?
代码:
Sub Level()
Dim calcmode As Long
Dim ViewMode As Long
Dim myStrings As Variant
Dim FoundCell As Range
Dim I As Long
Dim wsSkador As Worksheet
Dim ws As Worksheet
With Application
calcmode = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With
myStrings = Array("Apple", "Banan")
For Each ws In ActiveWorkbook.Worksheets
With ws.Range("A6:EE6")
For I = LBound(myStrings) To UBound(myStrings)
Do
Set FoundCell = .Find(What:=myStrings(I), _
After:=.Cells(.Cells.Count), _
LookIn:=xlFormulas, _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
If FoundCell Is Nothing Then
Exit Do
Else
FoundCell.EntireColumn.Delete
End If
Loop
Next I
End With
Next ws
End Sub
如果你在这里发表您的代码,你将有更多的运气,像megashares网站往往是由企业政策受阻。 – stuartd 2011-12-16 16:45:24
而不是张贴Excel文件,你应该显示一些代码,解释代码在做什么,你想要它做什么,以及到目前为止你试图让它工作。否则恐怕你不会得到任何帮助(我非常怀疑任何人都想打开一些从megashare下载的随机Excel文件...)。 – Quasdunk 2011-12-16 16:46:39