0
前面感謝您的任何幫助!excel宏在Windows XP中更改操作系統日期
構建宏以更新Excel(2010)VBA中主工作表(以下代碼)上工作項的完成日期。但是,每次運行宏時,我的操作系統(Windows XP)日期都會更改爲宏在主工作表上放置的日期。
例如,當我在主表單上更新12/1/2018時,我的任務欄上的日期更改爲12/1/2018,並且我收到日曆上每個定期會議的日曆通知,最多12/1/2018。
不知道我的代碼如何影響操作系統日期,但真的很感謝任何幫助,謝謝!
Sub UploadComplete()
'Uploads the date marker at contract on master
'Set up the array Contracts which will house the new contracts to be uploaded
Dim Contracts() As String
Dim size As Integer
Dim N As Integer
Dim R As Integer
'This sets up the value for N as the number (namely the row number) at the end of the
N = Worksheets("Master").Cells(Rows.Count, "A").End(xlUp).Row + 1
'Identifies which column to add the marker to
R = Application.WorksheetFunction.VLookup(Range("F2"), Worksheets("Update").Range("E14:G263"), 3, False)
'Determine size of array and store it into variable size
size = WorksheetFunction.CountA(Worksheets("Update").Columns(1))
'Having counted size can redim the array
ReDim Contracts(size)
'Insert the values in column A into the array
Dim i As Integer
For i = 1 To size
Contracts(i) = Worksheets("Update").Range("A1").Offset(i)
Next i
'Takes each value in the array and adds it to the end of the master list using N
For i = LBound(Contracts) To UBound(Contracts)
Worksheets("Master").Range("A" & N).Value = Contracts(i)
N = N + 1
Next i
'Remove the duplicates from the master tab based on the first column namely
'column A
Worksheets("Master").Range("A1:ZZ1000000").RemoveDuplicates Columns:=Array(1)
'Remove blank rows from Master
Dim rng As Range
Set rng = Worksheets("Master").Range("A1:A1000000").SpecialCells(xlCellTypeBlanks)
rng.EntireRow.Delete
'Find the contract from the imput grab the terminated date and put it into the master
For i = LBound(Contracts) To UBound(Contracts)
If Contracts(i) <> "" Then
Set rgFound = Worksheets("Update").Range("A2:A1000000").Find(Contracts(i), , , xlWhole)
Date = rgFound.Offset(, 1).Value
Set rgFill = Worksheets("Master").Range("A:A").Find(Contracts(i))
rgFill.Offset(, R) = Format(Date, "mm/dd/yyy")
rgFill.Offset(, R).Value = Date '?CHANGING DATE ON OS?
End If
Next i
'Remove blank rows from Master
Set rng = Worksheets("Master").Range("A1:A1000000").SpecialCells(xlCellTypeBlanks)
rng.EntireRow.Delete
End Sub
應該已經意識到Date是一個函數,我只是試圖用它作爲一個變量。非常感謝你的幫助!!! –
你應該看看[OPTION EXPLICIT](https://msdn.microsoft.com/en-us/library/y9341s4f.aspx)。這可以幫助避免這樣的問題。 – TmTron