VBA - IsNumber返回由于前缀而导致的任何内容

时间:2018-05-23 12:43:05

标签: excel vba excel-vba excel-formula

跟进问题来自:

VBA - Match Lookup With Multiple Parameters

下面的代码效果很好,但我已经意识到A列中的值有时会包含一个前缀,因此不返回任何内容。

希望有人可以编辑实际公式,以便在数字前面加上2个字母的前缀。

代码:

heat_template_version: 2016-10-14

description: Template to install HyperV Feature in Server

resources:
   floating_ip:
      type: OS::Neutron::FloatingIP
      properties:
         floating_network: Net_External_16

   instance:
      type: OS::Nova::Server
      properties:
         name: machine2
         flavor: LARGE
         networks:
            - network: 71xxxx85-8a24-475b-9xxc-169xxxxxbb0
         security_groups:
            - default
            - all_open
         block_device_mapping_v2:
            - device_name: /dev/vpa
              volume_id: {get_resource: volume}
              delete_on_termination: "true"
   volume:
      type: OS::Cinder::Volume
      properties:
         size: 25
         image: 51xxxxxbe-44e6-4206-920c-xxxxxxxxxx
         name: {get_param: volumename}

   ps_script:
      type: OS::Heat::SoftwareConfig
      properties:
         group: ungrouped
         config:
            str_replace:
               template: |
                  #ps1_sysnative
                  $log = New-Item "C:\check_file.txt" -Type File
                  start-sleep -s 20
                  install-windowsfeature -Name DNS -IncludeManagementTools
                  start-sleep -s 60
                  $pass = "_parameter_1_"
                  Add-content $log $pass

               params:
                  _parameter_1_: {get_param: parameter1}

   association:
      type: OS::Neutron::FloatingIPAssociation
      properties:
         floatingip_id: {get_resource: floating_ip}
         port_id: {get_attr: [instance, addresses, 71xxxxx85-8a24-4xxb-9xxc-16xxxx84bb0, 0, port]}

   deployment:
      type: OS::Heat::SoftwareDeployment
      properties:
         config: {get_resource: ps_script}
         server: {get_resource: instance }

outputs:
   instance_ip:
      description: Ipaddress
      value: {get_attr: [instance,addresses]}
   result:
     description: Checkoutput
     value: {get_attr: [deployent]}

A栏中的数据样本:

12345

24681

78956

AB12345

A78956

表中的数据也将包含前缀IF,其值为..实际上,MATCH正在寻找完全匹配。

链接到示例文件:

https://drive.google.com/file/d/1Uoa0Yn72nSckQaBnl6Y-a2q6UMJX6H3f/view?usp=sharing

1 个答案:

答案 0 :(得分:1)

此公式告诉您是否有2,1或0个非数字前缀。您可以使用此公式生成的数字来剪切数字前缀,然后进行匹配。

公式1:

=IF(ISNUMBER(NUMBERVALUE(LEFT(B2,1))),0,IF(ISNUMBER(NUMBERVALUE(RIGHT(LEFT(B2,2),1))),1,2))

如果字符串左起第一个字符是数字,则返回0,如果不检查从字符串左边的前两个字符开始形成的字符串右边的第一个字符是一个数字,如果那也是一个数字然后返回2,否则1

公式2:

=RIGHT(B2,LEN(B2)-C2)