VB程序员博客
在excel表中怎样编写一个vb小程序实现从一个sheet的单元格的内容拷贝到另一个sheet的单元各种?请大家帮帮忙,多谢哦!我写了一个小程序在运行时老提示错误如下:运行时错误'1004':应用程序定义的或对象定义的错误
代码如下:Private Sub CommandButton1_Click()
'Set xlbooks = Workbooks.Open("C:Documents and SettingsAdministrator桌面\Li Ling新建文件夹\GUI080710.xls")
Dim a, b, i
i = 3
a = Sheets("CompanyList").Cells(2, i)
b = Sheets("International").Cells(9, 3)
Do While a = b
Sheets("CompanyList").Select
Sheets("CompanyList").Cells(2, i).Select
Selection.Copy
Sheets("International").Select
Sheets("International").Cells(9, i).Select
ActiveSheet.Paste
Sheets("CompanyList").Select
Sheets("CompanyList").Range(Cells(4, i), Cells(8, i)).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("International").Select
Sheets("International").Range(Cells(10, i), Cells(14, i)).Select
ActiveSheet.Paste
ActiveWindow.SmallScroll Down:=6
Sheets("CompanyList").Select
Sheets("CompanyList").Range(Cells(10, i), Cells(11, i)).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("International").Select
Sheets("International").Range(Cells(21, i), Cells(22, i)).Select
ActiveSheet.Paste
Sheets("CompanyList").Select
Sheets("CompanyList").Cells(9, i).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("International").Select
Sheets("International").Cells(23, i).Select
ActiveSheet.Paste
i = i + 1
If a > b And a < b Then Exit Do
Loop
End Sub
急!请大家帮帮忙!!!!!!
好像你这个条件 If a > b And a < b Then Exit Do
在里面 这样条件不是没有用吗
是不是想写
If a > b Or a < b Then Exit Do
??
还不如写成这样
If a <> b Then Exit Do