Home > Software engineering >  VBA filtered according to the input values
VBA filtered according to the input values

Time:09-19



Just started learning VBA, want to accomplish: V38815 and V38816 cell is a drop-down menu, can choose>, acuity, <, or less; W38815 and W38816 input values, complete screening interval Settings, click on the filter based on the input value, display screen as a result,

Private Sub CommandButton1_Click ()
Screening
''
Selection. The AutoFilter
ActiveSheet. Range (" $A $1: $$38808 AJ "). The AutoFilter Field:=22, Criteria1:=_
"The Worksheets (" Sheet1"). The Range (" V38815: W38815 ") ", the Operator:=xlAnd, Criteria2:=_
"The Worksheets (" Sheet1"). The Range (" V38816, W38816 ") "
End Sub

So why not?

CodePudding user response:

Reference
V38815 and V38816 cell is a drop-down menu, you can select>, acuity, <, or less

This one doesn't need to write code, directly in the cell's data verification, validation criteria for sequence, input these symbols,
The first problem is the comparison of symbols you write wrong, should be the half Angle of symbol
 & gt; <>=& lt;=

Second question, the filter is wrong, should be values, rather than the Range
 Criteria1:="& gt; 5 "
Spell out 'with cell should be
Range (" V38815 ") & amp; Range (" W38815 ")

The third question, quotation is wrong, look at your writing should be a beginner? A variable on the quotation, it is a value equal to the variable name string , is no longer a variable, is to directly in your code into the IDE to red,
Final results are "& gt; 5 ", from "& gt;" And "5" spelled out, so the code is "& gt;" & "5", "& gt;" Compare symbol and "5" is V38815, W38815 cell values, so it should be
 Range (" V38815 ") & amp; Range (" W38815 ") 

CodePudding user response:

reference 1st floor Runnerchin response:
reference
V38815 and V38816 cell is a drop-down menu, you can select>, acuity, <, or less

This one doesn't need to write code, directly in the cell's data verification, validation criteria for sequence, input these symbols,
The first problem is the comparison of symbols you write wrong, should be the half Angle of symbol
 & gt; <>=& lt;=

Second question, the filter is wrong, should be values, rather than the Range
 Criteria1:="& gt; 5 "
Spell out 'with cell should be
Range (" V38815 ") & amp; Range (" W38815 ")

The third question, quotation is wrong, look at your writing should be a beginner? A variable on the quotation, it is a value equal to the variable name string , is no longer a variable, is to directly in your code into the IDE to red,
Final results are "& gt; 5 ", from "& gt;" And "5" spelled out, so the code is "& gt;" & "5", "& gt;" Compare symbol and "5" is V38815, W38815 cell values, so it should be
 Range (" V38815 ") & amp; Range (" W38815 ") 


Yes, it is just begin to contact thank you!

CodePudding user response:

All commented On the Error Resume Next statement, running in the VBA IDE,
The error and then click the debugging, the cursor will stop error in the statement,
Or
In doubt may have a logical error statements in advance to set breakpoints, run through the breakpoint interrupt,

At this point can be used in the immediate window
? The variable name
Or
? The function name () function parameter
Or
Process (parameters)
Auxiliary debugging,
  •  Tags:  
  • VBA
  • Related