Joke Collection Website - Public benefit messages - How to make a software or small program that can query information by itself?

How to make a software or small program that can query information by itself?

1, prepare data

Drag and drop the original data source into a row, then copy the header row of the original data source in the table and paste it into the blank column on the right.

Why do you want to drop a line from the original data? Because we will enter the conditional data in the second line on the right. If the second line is hidden when filtering, you can't enter conditions later. So in order to ensure that the second line is not hidden, the original data is pulled down by one line for processing.

Step 2 record macros

The key is this step. In the developer, click Record Macro.

Then under the Data tab, click Advanced Filter, and in the pop-up window, select A2:D 18 for the original list data.

Select F 1:I2 as the condition area, and then click OK.

In the development tool, stop recording macros.

At this time, you can press ALT+F 1 1, and you can see that VBA automatically records a line of code:

This code does not need to be modified.

3. Code for binding records

We insert a button in the development tool to automatically bind the macro we just recorded, or right-click the button to bind the macro. We enter the year 1992, click Query, and the result comes out.

Principle of operation method:

That is, you can query data under certain conditions, such as entering the keyword you want to search, employee Xiao Qiao, and clicking Query can query Xiao Qiao's information.

You can also query when multiple conditions are met. For example, you can query the men in the marketing department and click Query to get the results.

The above query system is very tall, and it seems that it needs very complicated VBA programming to realize it. In fact, it can be easily solved with a simple recording macro.