我尝试为下表创建advanced filter
,但下面的代码只是隐藏了单元格。它的工作但我的问题是,如果我过滤一些东西,然后我拖动以填充状态或任何其他单元格,它将覆盖其间的单元格,例如在过滤器模式中我有2行,一行是第一行,另一行一个是在第20行,如果我拖动填充状态,它将替换1到20之间的所有单元格的状态,并且不知道如何解决它,我知道这是因为我隐藏了单元格并没有实际过滤它们。
非常感谢任何帮助。
[数据表] [1]
Private Sub Worksheet_Change(ByVal Target As Range)
Application.ScreenUpdating = False
Application.EnableEvents = False
r1 = Target.Row
c1 = Target.Column
If r1 <> 3 Then GoTo ending:
If ActiveSheet.Cells(1, c1) = "" Then GoTo ending:
Dim LC As Long
With ActiveSheet
LC = .Cells.Find(What:="*", After:=[A1], SearchOrder:=xlByColumns, SearchDirection:=xlPrevious).Column
End With
ActiveSheet.Range("4:10000").Select
Selection.EntireRow.Hidden = False
LR = Cells.Find(What:="*", After:=[A1], SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
For r = 5 To LR
For c = 1 To LC
If ActiveSheet.Cells(2, c) = "" Or ActiveSheet.Cells(3, c) = "" Then GoTo nextc:
If ActiveSheet.Cells(2, c) = "exact" And UCase(ActiveSheet.Cells(r, c)) <> UCase(ActiveSheet.Cells(3, c)) Then ActiveSheet.Rows(r).EntireRow.Hidden = True: GoTo nextr:
If Cells(2, c) = "exact" Then GoTo nextc:
j = InStr(1, UCase(ActiveSheet.Cells(r, c)), UCase(ActiveSheet.Cells(3, c)))
If ActiveSheet.Cells(2, c) = "partial" And j = 0 Then ActiveSheet.Rows(r).EntireRow.Hidden = True: GoTo nextr:
nextc:
Next c
nextr:
Next r
ending:
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub
答案 0 :(得分:0)
以下代码将是关于如何根据用户在表格中选择的内容的多个条件创建高级搜索的问题的答案。
我需要一些帮助,如何检查用户是否错误选择了一个空单元格,我需要使excel忽略过滤空白单元格。另外,我需要首先制作excel以检查黄色单元格A3到T3是否有数据,如果有,我按下过滤器按钮将按范围A3:T3过滤,如果没有数据则忽略当前用户选择在范围A3中:T3将根据用户选择进行过滤,在A3:T3范围内,如果有数据,则仅按数据单元过滤,并忽略空数据。
func textOnImage(text: NSString, atPoint: CGPoint,capturedImage:UIImage?) -> UIImage?{
if let capturedImage = capturedImage{
// Setup the font specific variables
let textColor = UIColor.white
let textFont = UIFont(name: "Helvetica", size: 14)!
// Setup the image context using the passed image
let scale = UIScreen.main.scale
UIGraphicsBeginImageContextWithOptions(capturedImage.size, false, scale)
// Setup the font attributes that will be later used to dictate how the text should be drawn
let textFontAttributes = [
NSFontAttributeName: textFont,
NSForegroundColorAttributeName: textColor,
] as [String : Any]
capturedImage.draw(in: CGRect(x: 0, y: 0, width: capturedImage.size.width, height:capturedImage.size.height))
// Create a point within the space that is as bit as the image
let rect = CGRect(x: atPoint.x, y: atPoint.y, width: capturedImage.size.width, height: capturedImage.size.height)
// Draw the text into an image
text.draw(in: rect, withAttributes: textFontAttributes)
// Create a new image out of the images we have created
let newImage = UIGraphicsGetImageFromCurrentImageContext()
// End the context now that we have the image we need
UIGraphicsEndImageContext()
//Pass the image back up to the caller
return newImage!
}
return nil
}
}