返回列表 上一主題 發帖

請問如何存檔

請問如何存檔

最近有貼別人寫的excel 裡面寫的vba的程式
但是很怪的是貼了之後
都可以跑
但是存完檔之後
下次在開的時候發現程式碼又不見了
大大告知一下為什麼都存不起來
感謝

我的存檔類型如下
Microsoft Office Excel 工作表

TOP

回復 5# GBKEE

板主你好
這是我要貼的程式碼

    Sub SyncData()

    On Error GoTo ErrorHandler
   
    Dim i As Integer
    Dim j As Integer
   
    If Not ((Sheet1.Cells(10, 3) = "13:44:59") Or (Sheet1.Cells(10, 3) = "13:45:00")) Then
   
        i = Round(DateDiff("s", TimeValue("09:00:00"), TimeValue(Sheet1.Cells(3, 3))) / 60 / 5, 0) + 1
        Do While (Sheet3.Cells(i, 1) <> "")
        
            If (Sheet3.Cells(i, 1) = Mid(Sheet1.Cells(3, 3), 1, 5)) Then
                Sheet3.Cells(i, 2) = Sheet1.Cells(20, 3)
                Sheet3.Cells(i, 3) = Sheet1.Cells(7, 3)
                Exit Do
            End If
            
            i = i + 1
        Loop
        
        i = Round(DateDiff("s", TimeValue("09:00:00"), TimeValue(Sheet1.Cells(3, 3))) / 60, 0) + 1
        j = i
        Do While (Sheet3.Cells(i, 6) <> "")
        
            If (Sheet3.Cells(i, 6) = Mid(Sheet1.Cells(3, 3), 1, 5)) Then
                Sheet3.Cells(i, 7) = Sheet1.Cells(4, 3)
                Sheet3.Cells(i, 8) = Sheet1.Cells(11, 3)
                Exit Do
            End If
            
            i = i + 1
        Loop
        
        If (InStr(5, Sheet1.Cells(10, 3), ":30") > 0) Then
            ActiveWorkbook.Save
        End If
   
    End If
   
    Exit Sub
   
ErrorHandler:
   
    'MsgBox "eMail to E.Y. ~ " + Err.Description
   
End Sub


Sub EraseData()
   
    Sheet3.Activate
   
    Sheet3.Range("B2:C55").Select
    Selection.ClearContents
   
    Sheet3.Range("G2:H271").Select
    Selection.ClearContents
   
    Sheet1.Activate

    ActiveWorkbook.Save

End Sub

TOP

回復 6# mark15jill


   感謝
  已存檔成功
  原來要存成 Microsoft Office Excel 啟用巨集的工作表
  才能存檔

TOP

回復 9# mark15jill


    感謝分享
   謝謝

TOP

        靜思自在 : 能善用時間的人,必能掌握自己努力的方向。
返回列表 上一主題