如果匹配则更改文本?

时间:2015-06-23 23:07:49

标签: excel vba excel-vba

现在我从工作表1 B列中复制数据。

我想要它,以便它不会复制它只是放置已完成,如果它显示已完成或未完成,如果它显示未完成。现在它将我接下来的额外信息复制到Completed。

<Page x:Name="ChatPageName" x:Class="WindowsDesktop.Chat.ChatPage"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
      xmlns:local="clr-namespace:WindowsDesktop.Chat"
      mc:Ignorable="d" 
      d:DesignHeight="300" d:DesignWidth="300"
   Title="ChatPage">
<Grid>
    <ToolBar x:Name="ToBar" Grid.Row="0" HorizontalAlignment="Left" Margin="10,42,0,0" VerticalAlignment="Top" Height="28" Width="280">
        <TextBox x:Name="ToBarTextBox" Height="22.6666666666667" Margin="0" TextWrapping="Wrap" Text="{Binding Path=ToBarText, Source=ChatPageName}" VerticalAlignment="Top" Width="120"/>
        <Button x:Name="AddContactButton" Content="Add" Height="23" VerticalAlignment="Top" Width="75" Margin="0,0,0,-0.333" Click="AddContactButton_Click"/>
    </ToolBar>

1 个答案:

答案 0 :(得分:0)

所以我认为这对你有用,但如果它没有做你所要求的,请告诉我。在旁注中,iferror(...,"error value")if(iserror(...,"error value",...)的良好替代品。它使您不必再输入两次测试条件。

With Sheets("Worksheet 2")
    .Range("B1").Formula = "=IFERROR(IF(IFERROR(FIND(""Not Completed"",VLOOKUP(A1,'WorkSheet 1'!A:B,2,0)),0),""Not Completed"",IF(IFERROR(FIND(""Completed"",VLOOKUP(A1,'WorkSheet 1'!A:B,2,0)),""""),""Completed"","""")),"""")"
    .Range("B1").Copy Range("B2:B" & Range("A" & Rows.Count).End(xlUp).Row)
End With