![](/img/trans.png)
[英]How can I transfer an image from a cell in Excel to the Word header (left) VBA
[英]How can I transfer an input text as a date to an Excel cell in VBA
當我傳輸行時,即使單元格被定義為日期,也會始終顯示錯誤的數據類型或用戶定義的數據類型。 所以顯然不是日期而是一個字符串被傳輸。 如何將字符串 txtEnd 作為日期傳遞。 我試過了,但沒有用。
謝謝您的幫助。
此致
Private Sub CommandButton1_Click()
Dim iRow As Long
iRow = Tabelle1.Range("C" & Rows.Count).End(xlUp).Row + 1
With Tabelle1
.Range("C" & iRow).Value = Me.txtTask.Value
.Range("D" & iRow).Value = Me.txtDescription.Value
.Range("E" & iRow).Value = "important"
.Range("F" & iRow).Value = "open"
.Range("G" & iRow).Value = "not started"
.Range("H" & iRow).Value = "not started"
.Range("I" & iRow).Value = Me.txtBegin.Value
.Range("J" & iRow).Value = Me.txtEnd.Value
.Range("K" & iRow).Value = "0 %"
End With
With Me
For Each ctl In .Controls
If TypeName(ctl) = "TextBox" Then
ctl.Value = vbNullString
End If
Next
End With
End Sub
Private Sub txtEnd_AfterUpdate()
On Error Resume Next
Me.txtEnd = CDate(Me.txtEnd)
End Sub
如果您希望將 txtEnd 中的值作為日期輸入到列 J 中,請使用 DateValue
.Range("J" & iRow).Value = DateValue(Me.txtEnd.Value)
這應該在 J 列中為您提供一個日期值,您可以根據需要對其進行格式化。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.