重新打开文件后,条件格式失败

时间:2019-01-19 00:40:29

标签: excel vba conditional-formatting

以下操作按预期进行,但是一旦我关闭并重新打开excel文件,它就会失败,并且仅在我更改同一列中的内容,添加/删除选项卡或文件加载时才执行一次。击中F9不会执行任何操作。如果我手动进入现有的条件格式并重新应用,即使不进行任何更改,它仍然可以再次正常工作,但是关闭并重新打开文件也有同样的问题。

def sigmoid(x, deriv=False):
    if deriv == True:
        return x*(1-x)
    return 1/(1+np.exp(-x))

    X = np.array([[0,0,1],
              [0,1,1],
              [1,0,1],
              [1,1,1]])

    y = np.array([0,0,1,1]).T

    w0 = np.random.normal(0,0.1,(3,1))
    w0.shape


    for iter in range(10000):
      #forward propagation
      #l0 = X
      multiply = np.dot(X,w0)
      if iter == 1: print(multiply.shape)


      l1 = sigmoid(multiply)
      if iter == 1:
          print(w0)
          print(multiply.shape)
          print(X.shape)
          print(w0.shape)
          print(l1.shape)

      #Calculating error:
      error = y-l1
      if iter == 1: print(error.shape)

      #Backpropagating for update
      d_l1 = error*sigmoid(l1, True)
      if iter == 1: print(d_l1.shape)

      #Update weights : Shape -- (4*3).T * (4*1) = (3*1)
      w0 = w0 + np.dot(np.transpose(X), d_l1.T) 

print ('Results after training:')
print (l1)

我已隔离此代码,并且仍然会发生。 由于根本没有任何错误,我将如何解决或重新处理此问题。

Excel版本2013和2010。

谢谢。

2 个答案:

答案 0 :(得分:0)

我有Office 2003 Professional,但这仍然适用,因为它可能是事件和位置驱动的。

我猜您不是在ThisWorkbook对象的Workbook_Open事件上运行代码,而是在工作表中的某个地方运行代码。

因此,您应该将代码放入Workbook_Open事件中,然后尝试尝试。

    'This is code on the ThisWorkbook Object
    '-------------------------------------------
    Option Explicit

    Private Sub Workbook_Open()

        Sheet1.Columns("D:D").Select
        Selection.FormatConditions.Delete
        Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlGreater, _
            Formula1:="0"
        Selection.FormatConditions(1).Interior.ColorIndex = 44
        Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlLess, _
            Formula1:="1"
        Selection.FormatConditions(2).Interior.ColorIndex = 35
    End Sub


答案 1 :(得分:0)

找到了解决方法。

已更改

rngShop = "C1" & ":" & Cells(lRowEnd, 3).Address(False, True)

收件人

rngShop = "C1" & txtShopFree 

    .FormatConditions.Add Type:=xlExpression, Formula1:="=" & rngShop & txtShopFree

收件人

    .FormatConditions.Delete
    .FormatConditions.Add Type:=xlExpression, Formula1:="=" & rngShop
相关问题