excel programming一問

2011-07-20 12:41 am
我打左以下code:

Sub 按鈕1_Click()
Dim i As Integer
For i = 5 To 45
If Cells(i, "A") <> "" Then
Cells(i, "B") = Cells(i, "A")
Else
End If
Next i
End Sub

但係呢個只可以係同一張sheet做
我想問, 如果我想


If [Sheet1]Cells(i, "A") <> "" Then
[Sheet2]Cells(i, "B") = [Sheet1]Cells(i, "A")

咁應該要點打?

thanks~

回答 (1)

2011-07-20 1:47 am
✔ 最佳答案
Sub 按鈕1_Click()
Dim i As Integer
For i = 5 To 45
If Sheets(1).Cells(i, "A") <> "" Then
Sheets(2).Cells(i, "B") = Sheets(1).Cells(i, "A")
Else
End If
Next i
End Sub


2011-07-19 17:52:53 補充:
假如
Sheet1 名 表123
Sheet2 名 表456

除左用sheets(1),sheets(2)去指定尼2個工作表.
亦可以寫成 : Sheets("表123") 同埋 Sheets("表456")


收錄日期: 2021-04-16 13:04:18
原文連結 [永久失效]:
https://hk.answers.yahoo.com/question/index?qid=20110719000051KK00755

檢視 Wayback Machine 備份