返回列表 上一主題 發帖

對話框

有出入,當對話框輸入數字時
         應該是Again 而非Exit
         按取消才是離開myleoyes 發表於 2010-7-22 22:11

應該是Again 那就使用 Go To  Again
按取消 ->=False  你可以試著修改啊

TOP

回復 3# GBKEE
kimbal前輩你好!
       前輩!謝謝!項目程式你可能誤解,
       這裡是約束對話框只接受文字輸入!
       而註解是在於不留白
       因為空白註解是無異議的
       如良師的程式就是小弟的需求
       謝謝再三!!!

GBKEE前輩你好!
     良師!謝謝!項目程式與小弟的需求
         有出入,當對話框輸入數字時
         應該是Again 而非Exit
         按取消才是離開請再辛苦一下謝謝再三!!

TOP

回復 1# myleoyes
  1. Sub 項目()
  2.        Dim Z, Msg As Boolean
  3.        Z = Application.InputBox("請輸入項目名稱", , "早安!", Type:=2)
  4.        If Z <> False Then
  5.             Msg = False
  6.             For I = 1 To Len(Z)
  7.                 If Mid(Z, I, 1) Like "[!0-9]" Then Msg = True: Exit For '判定是字串
  8.             Next
  9.             If Msg Then
  10.                 ActiveCell = Z
  11.             Else
  12.                 ActiveCell = ""
  13.             End If
  14.        ElseIf Z = False Then
  15.             ActiveCell = ""
  16.        End If
  17.        ActiveCell.Offset(, 1).Select
  18. End Sub

  19. Sub 註解()
  20.         If ActiveCell.Comment Is Nothing Then ActiveCell.AddComment
  21.         ZZ = InputBox("請輸入附註", , ActiveCell.Comment.Text)
  22.         If ZZ = "" Then ActiveCell.Comment.Delete: Exit Sub
  23.         ActiveCell.Comment.Text Text:=ZZ
  24. End Sub
複製代碼

TOP

各位前輩你們好!
        前輩!問題如附檔案說明
          Sub 註解()
             If Not ActiveCe ...
myleoyes 發表於 2010-7-22 08:12



    問題一:
你的意思是如果項目有東西, 就顯示原來的對吧?
首先在Worksheet_SelectionChange解除一下
  1. If Target(1) = "" Then 項目
  2. end if
複製代碼
直接運
  1. 項目
複製代碼
然後把項目改成以下的
  1. Sub 項目()
  2.        Dim Z As string
  3.        If ActiveCell <> "" Then
  4.             z = ActiveCell
  5.         Else
  6.             z = "早安!"
  7.         End If
  8.        Z = ActiveCell.value
  9.        Z = Application.InputBox("請輸入項目名稱", , z, Type:=2)
  10.        ActiveCell.value = z
  11.        ActiveCell.Offset(, 1).Select
  12. End Sub
複製代碼
問題二: (小弟午飯時間快過 , 暫提供代碼, 有需要的話今晚再解釋解釋)
  1. Sub 註解()
  2.         If Not ActiveCell.Comment Is Nothing Then
  3.             ZZ = InputBox("請輸入附註", , ActiveCell.Comment.Text)
  4.         Else
  5.             ZZ = InputBox("請輸入附註", , "")
  6.             ActiveCell.AddComment
  7.         End If
  8.         ActiveCell.Comment.Text Text:=ZZ
  9. End Sub
複製代碼
懂得發問,答案就會在其中

今日の一秒は  明日にない
http://kimbalko-chi.blogspot.com
http://kimbalko.blogspot.com

TOP

        靜思自在 : 君子如水,隨方就圓,無處不自在。
返回列表 上一主題