单击输入时如何从单元格中减去值?

时间:2016-09-29 14:00:41

标签: excel

当用户在添加值后按Enter键时,是否有任何方法可以激活excel中的功能。 例如,每次用户向A4单元格输入新值并按Enter

时,我想执行case 'email_exists': if (!is_email($input_value)) { $output['error'] = __('Please enter a valid email.','userpro'); } else if (email_exists($input_value)) { $output['error'] = __('Email is taken. Is that you? Try to <a href="#" data- template="login">login</a>','userpro'); } else if($input_value){ $domain = strstr($input_value, '@'); $domains = array('@test.com' , '@test.net' , '@alpha.test.com' , '@beta.test.net', '@*.test.com', '@*.test.net'); if(!in_array($domain, $domains)) $output['error'] = __('Accounts with this email domain are not currently allowed automatic registration. You can request an account via the contact us page. ','userpro'); } break;

2 个答案:

答案 0 :(得分:1)

一种方法是转到文件&gt;选项&gt;公式和集计算选项&gt;工作簿计算到手册。

然后告诉您的用户点击F9以显示结果。

答案 1 :(得分:0)

您需要将以下子例程放在VBA中的ThisWorkbook excel对象中(可通过按Alt + F11访问):

Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Intersect(Target, Range("A4")) Is Nothing Then
        Target.Value = Range("A3").Value - Target.Value
    End if
End Sub

有关Worksheet_Change事件的更多信息,请参阅here