Private Sub Command1_Click(Index As Integer)
INDEX=1時就是Command1(1),INDEX=2就是Command1(2)。可以這樣:
SELECT CASE INDEX
CASE 1
按下Command1(1)時
CASE 2
按下Command1(2)時
.
.
.
END SELECT
End Sub
2.如何設定按鈕點擊就會複製指定區域的數值兄弟這個不需要寫什麼代碼。只需要錄製一下宏就行了。
Sub Macro1()
Range("B2:D20").Select
Selection.Copy
Range("H5").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End Sub
Sub macro2()
Range("B2:D20").Select
Selection.Copy
Sheets("Sheet2").Select
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End Sub
創建二個按鈕,指定這二個宏行了
3.複製和粘貼的代碼要怎麼寫Private Sub CmdCopy_Click()
Clipboard.Settext TxtContent.SelText
End Sub
Private Sub CmdPaste_Click()
TxtContent.SelText = Clipboard.GetText
End Sub
Private Sub CmdCopy_Click()
'這只是按鈕代碼的起始而已,按鈕名叫做CmdCopy,事件是單擊
Clipboard.SetText TxtContent.SelText
'Clipboard指剪貼板;SetText是剪貼板對象的一個方法,用來設定剪貼板的內容;TxtContent是指一個文字方塊;SelText是文字方塊的一個屬性,指文字方塊的內容
'翻譯過來就是把剪貼板的內容設爲文字方塊的內容,就是複製(因爲原內容並沒有消失,要實現剪切,在這句後面加一句TxtContent.SelText = "")
End Sub
'代碼完畢
Private Sub CmdPaste_Click()
'按鈕名叫CmdPaste,事件是單擊
TxtContent.SelText = Clipboard.GetText
'TxtContent.SelText參見上文。Clipboard仍然指剪貼板,GetText指剪貼板的內容,是一個屬性)
'翻譯過來就是把文字方塊的內容設爲剪貼板的內容,就是粘貼了
End Sub
4.求單擊按鈕能複製文字方塊內容的代碼樣式.blockcode .headactions { color: #333; font-size: 12px; cursor: pointer; padding-top: 8px; } 中cursor: pointer;就是鼠標爲小手形狀了=====================================================<style> h5{ margin: 0; padding: 0; } .headactions { float: right; line-height: 1em; padding: 10px 10px 0 0; } .t_msgfont { font-size: 14px; line-height: 1.6em; } .t_msgfont * { line-height: normal; } .t_msgfont li { margin-left: 2em; } .blockcode { font-size: 12px; margin: 10px 20px; border: solid #5B5B5B; border-width: 4px 1px 1px; background: #EAEAEA url(".cn/images/default/portalbox_bg.gif"); background- repeat: repeat-x; background-position: 0 0; overflow: hidden; } .blockcode h5 { border: 1px solid; border-color: #EAEAEA #EAEAEA #5B5B5B #EAEAEA; line-height: 26px; padding-left: 5px; color: #333; } .blockcode code { margin: 1em 1em 1em 3em; line-height: 1.6em; } .blockcode code { font: 14px/1.4em "Courier New", Courier, monospace; display: block; padding: 5px; } .blockcode .headactions { color: #333; font-size: 12px; cursor: pointer; padding-top: 8px; } </style> copycode(document.all.codetext);" >複製內容到剪貼板
代碼:
文字的內容
PS:分分^_^Y。