将变量的值添加到循环中的te next变量中

时间:2015-10-18 21:28:59

标签: excel-vba foreach vba excel

我需要在我编写的代码中提供帮助,此代码将遍历E列中的每个单元格,如果它在列中找到单词“Total”,则会为变量ChargebleHours指定F中单元格的值代码为同一行的列:

Sub ChargeableHours()
DIM E as Range,F as Range, r as Range
SET E = Intersect(ActiveSheet.UsedRange, Range("E:E"))
FOR Each r IN E
   If Left(r.Text,5) = "Total" Then
      ChargebleHours = Cells(r.Row,"F").Value
   End If
Next r
EndSub

现在我在实现第二个循环时遇到了麻烦,它存储了之前找到的变量ChargebleHours的值,并添加到它找到的下一个值。

1 个答案:

答案 0 :(得分:0)

也许你的意思是这样的:

var $app = angular.module('app', ['angular-stripe']);
$app.constant('devDomains', ['localhost', 'staging.mydomain.com']);
$app.constant('stripePubKeyStaging', 'STRIPE_PUB_KEY_HERE');
$app.constant('stripePubKey', 'STRIPE_PUB_KEY_HERE');

$app.config(function(devDomains, stripePubKey, stripePubKeyStaging, stripeProvider) {
  if (devDomains.indexOf(document.location.hostname) !== -1 || document.location.search.indexOf('stripe-test-key') !== -1) {

    // if you're running your angular app on local or staging, use the test key. Additionally 
    // if you load your page with ?stripe-test-key you can force your production app 
    // to use the test key in order to debug something on live if you'd like.
    stripeProvider.setPublishableKey(stripePubKeyStaging);
  } else {
    stripeProvider.setPublishableKey(stripePubKey);
  }
});

或者这个:

ChargebleHours = ChargebleHours + Cells(r.Row,"F").Value