怎么用edittext得到日期_excel查找函数:如何用Vlookup进行多条件查找

da1eb1059716ffd77911d1ba59729c36.png

编按:通过日期和另一个条件如姓名进行查找,但是辅助列中日期变成了数字,那这时还能用Vlookup进行查找吗?还有,能不能不用辅助列进行多条件查找呢?

8863a10aeb1d4c716e08d3c0c2d68162.png

一、日期迷思

最近有学员在使用vlookup进行双条件查找时遇到了困难:

edb6c6c93ea974a50b586d8b634181f6.png

归纳起来就是两个问题:

添加“姓名&日期”辅助列,但是辅助列的结果始终不对,这是怎么回事?

885ea3366af13074bf420cbdf235dc55.png

38c94389914c5853f2ff76dbbb58d60d.png

能不能不用辅助列实现姓名和日期双条件查询?

70734a4e7b7f23ea76aae5e321f0b6f5.png

通常使用Vlookup函数进行多条件查找的时候,使用辅助列是个不错的选择。使用“&”符号将两列或者多列值连接生成辅助列,然后再用“&”符号将两个或者多个条件串起来当作查找值即可。这位同学的第一解决方案也正是这样的:添加“姓名&日期”辅助列,然后用Vlookup查询“G2&H2”。可是当同学发现辅助列原本应该得到姓名加日期的,却变成了姓名加数字,于是就不敢继续使用Vlookup查询了。

他完全被这个莫名其妙的日期变化给弄迷糊了!!

f4e9b05d16860fcb8a1d5c6b10766559.png

二、vlookup并没有失效

或许类似的问题大家也遇到过,其实完全不必被这个日期数字的变化给吓到,给迷惑,vlookup并没有那么不堪:

32f19680e1505867d1c9318426350613.png

从上图可以看到,虽然辅助列姓名后不是日期,但我们使用vlookup进行查找还是能得到正确的结果,这是怎么回事呢?

三、日期与数字之间的秘密

日期与数字之间到底有何联系,我们通过一个小测试就能明白了:

ea5c283a2f742568221c123d3144b47d.gif

明白了吗?将日期所在的单元格改成常规格式,日期就变成数字了,所以经常会听到这样一种说法:日期本质是数字!

关于日期和数字之间的关系,懂得下面这几个要点就可以了:

1.日期是一种特殊形式的数据,一个日期对应一个常规数字,但是反过来一个数字不一定对应一个日期;

2.在EXCEL中日期是有范围的,从1900-1-1到9999-12-31,对应的数字是1到2958465,超出范围就显示错误;

b1449c6c44c7108aefba70b6d46868f5.gif

注意:0虽然可以转换为日期,但是这个日期并没有实际意义;当数字超出范围后,转为日期格式时会显示为一串#。

3.想要知道数字代表哪个日期,或者是日期等于哪个数字,通过设置单元格格式为日期或者常规即可;

4.通常在公式中,日期被当成数字处理。

四、可以用TEXT函数把数字显示为日期

明白了上面的几点,自然就知道虽然辅助列姓名后是数字而非日期,但仍然可以使用Vlookup函数正常查找。如果非要姓名后的数字显示为日期不可,需要使用TEXT函数进行强制显示:

8b6e083c29089d07a28968fd6cc72de2.png

公式为:=B2&TEXT(C2,"e年m月d日")

TEXT函数的用法很简单:TEXT(数据,”格式代码”),其作用就是将数据按照指定的格式显示出来。格式代码一定要加引号(英文状态)。e表示年(也可以用yyyy表示年),m表示月,d表示日。

到此,同学的第一个问题就解决了。下面看看第二个问题。

五、不用辅助列Vlookup多条件查找

第二个问题,能否不用辅助列使用Vlookup进行多条件查找?完全可以!

我们既然可以用“&”符号把两个条件连接起来当成一个查找值使用,当然也有办法把查找区域中的B列、C列当成1列来使用。使用IF函数数组形式,我们可以把查找范围B:D变成B&C:D,然后进行查找:

2d2709d1b58dcf2e5db9b85f78a5bfcc.png

注意:公式=VLOOKUP(F2&G2,IF(,B2:B34&C2:C34,D2:D34),2,0)是一个数组公式,输入后须要按Ctrl+Shift+Enter,然后再向下填充公式,否则公式填充后结果可能显示为错误#N/A。

***说明:本文主要由老菜鸟写作。小雅完成第五节。

****部落窝教育-excel多条件查找****

原创:老菜鸟、小雅/部落窝教育(未经同意,请勿转载)

更多教程:部落窝教育(http://www.itblw.com)

微信公众号:exceljiaocheng

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
下面是Android Studio失物招领模块Xml文件的实现代码,请修改代码实现下拉以及图片上传功 <TextView android:id="@+id/shiwuzhaolingzi" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="请选择是失物还是招领" /> <Spinner android:id="@+id/spinner_lost_found" android:layout_width="match_parent" android:layout_height="wrap_content" android:entries="@array/lost_found_array" /> <TextView android:id="@+id/text_item_name" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="物品名称" /> <EditText android:id="@+id/edit_item_name" android:layout_width="match_parent" android:layout_height="wrap_content" android:inputType="text" /> <TextView android:id="@+id/text_item_desc" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="物品描述" /> <EditText android:id="@+id/edit_item_desc" android:layout_width="match_parent" android:layout_height="wrap_content" android:inputType="text" /> <TextView android:id="@+id/text_item_time" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="时间" /> <EditText android:id="@+id/edit_item_time" android:layout_width="match_parent" android:layout_height="wrap_content" android:inputType="text" /> <TextView android:id="@+id/text_item_location" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="地点" /> <EditText android:id="@+id/edit_item_location" android:layout_width="match_parent" android:layout_height="wrap_content" android:inputType="text" /> <Button android:id="@+id/button_upload_image" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="上传图片" /> <TextView android:id="@+id/text_image_path" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="图片路径:" /> <Button android:id="@+id/button_submit" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="提交" /> </LinearLayout>
最新发布
05-17
以下是修改后的代码实现下拉和图片上传功能: <TextView android:id="@+id/shiwuzhaolingzi" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="请选择是失物还是招领" /> <Spinner android:id="@+id/spinner_lost_found" android:layout_width="match_parent" android:layout_height="wrap_content" android:entries="@array/lost_found_array" /> <TextView android:id="@+id/text_item_name" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="物品名称" /> <EditText android:id="@+id/edit_item_name" android:layout_width="match_parent" android:layout_height="wrap_content" android:inputType="text" /> <TextView android:id="@+id/text_item_desc" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="物品描述" /> <EditText android:id="@+id/edit_item_desc" android:layout_width="match_parent" android:layout_height="wrap_content" android:inputType="text" /> <TextView android:id="@+id/text_item_time" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="时间" /> <EditText android:id="@+id/edit_item_time" android:layout_width="match_parent" android:layout_height="wrap_content" android:inputType="text" /> <TextView android:id="@+id/text_item_location" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="地点" /> <EditText android:id="@+id/edit_item_location" android:layout_width="match_parent" android:layout_height="wrap_content" android:inputType="text" /> <Button android:id="@+id/button_upload_image" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="上传图片" android:onClick="onUploadImageClick" /> <TextView android:id="@+id/text_image_path" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="图片路径:" /> <Button android:id="@+id/button_submit" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="提交" android:onClick="onSubmitClick" /> <!-- 添加下拉框选项数组 --> <string-array name="lost_found_array"> <item>失物</item> <item>招领</item> </string-array> <!-- 添加文件选择器 --> <com.github.dhaval2404.imagepicker.ImagePicker android:id="@+id/imagePicker" android:layout_width="wrap_content" android:layout_height="wrap_content" /> 修改后的Java代码: public class MainActivity extends AppCompatActivity { private Spinner mSpinnerLostFound; private EditText mEditItemName; private EditText mEditItemDesc; private EditText mEditItemTime; private EditText mEditItemLocation; private TextView mTextImagePath; private Button mButtonUploadImage; private Button mButtonSubmit; private ImagePicker mImagePicker; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // 初始化控件 mSpinnerLostFound = findViewById(R.id.spinner_lost_found); mEditItemName = findViewById(R.id.edit_item_name); mEditItemDesc = findViewById(R.id.edit_item_desc); mEditItemTime = findViewById(R.id.edit_item_time); mEditItemLocation = findViewById(R.id.edit_item_location); mTextImagePath = findViewById(R.id.text_image_path); mButtonUploadImage = findViewById(R.id.button_upload_image); mButtonSubmit = findViewById(R.id.button_submit); mImagePicker = new ImagePicker(this); // 创建文件选择器 // 设置上传图片按钮点击事件 mButtonUploadImage.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mImagePicker.choosePicture(true /* allow camera */); } }); // 设置提交按钮点击事件 mButtonSubmit.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // TODO: 实现数据提交逻辑 } }); } // 在Activity中添加以下两个方法以便与文件选择器交互 @Override protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { super.onActivityResult(requestCode, resultCode, data); mImagePicker.handleActivityResult(requestCode, resultCode, data); } public void onUploadImageClick(View view) { // 显示文件选择器 mImagePicker.choosePicture(true /* allow camera */); } }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值