简体   繁体   English

如何在Excel VBA的公式栏中获取单元格值?

[英]How to get cell value in the formula bar in Excel VBA?

I have an Excel data sheet and this sheet has a cell that the visible value and the value in the formula bar are different. 我有一个Excel数据表,该表有一个单元格,该单元格的可见值与编辑栏中的值不同。

I used Cell.Value but it returns the visible value. 我使用了Cell.Value但它返回了可见值。 I want to get the value in the bar. 我想在栏中获取价值。

Image to understand question: 图片了解问题:

在此处输入图片说明

I mean the visible value is MMK333098333101 and the bar value is MMK333098. 我的意思是可见值是MMK333098333101,条形值是MMK333098。

So how can I get the bar value in VBA Excel? 那么如何在VBA Excel中获取条形值?

The bar value is both. 柱线值均为。 If you drag the bar down you will see both values. 如果将栏拖下,您将看到两个值。 It is separated by a line insert. 它由行插入符分隔。 You can't see the second line because you are only showing one line in the formula bar. 您看不到第二行,因为您仅在编辑栏中显示一行。

在此处输入图片说明

If you want the first part then you will need to use LEFT and Find to find the carriage return and take all the values before it. 如果需要第一部分,则需要使用LEFT和Find来查找回车符并获取它之前的所有值。

=LEFT(A1,FIND(CHAR(10),A1)-1)

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM