求助,Excel的VBA编程的问题!!

cjl1001 2006-06-01 01:22:54
用Excel的VBA编程,如果我要把选择的东西粘贴下来,应该怎么写?
我们老师要求我们用EXCEL的VBA来编程计算金融里的东西。

我写的一直有问题,就是粘贴时出错,

谢谢了!!
...全文
244 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
bj3743 2006-06-07
  • 打赏
  • 举报
回复
录制个拷贝,选择性粘贴的宏试试
supercase 2006-06-03
  • 打赏
  • 举报
回复
Range("A1:E12").Select
Selection.Copy
Sheets("Sheet2").Select
ActiveSheet.Paste
cjl1001 2006-06-01
  • 打赏
  • 举报
回复
这是那个宏,有3步。

Sub CopyDayOfWeek()

Dim NoOfRows As Integer
Dim i As Integer, j As Integer
Dim inputrange As Range
Dim outrange As Range


Set inputrange = Application.InputBox("select the filtered range", "Filtered Range", , , , , , 8)

inputrange.Select
Selection.Copy

Set outrange = Application.InputBox("Enter the output worksheet or range", "CopyDayOfWeek", , , , , , 8)

outrange.Select
ActiveSheet.Paste

End Sub


Sub CopyDayOfWeek1()

Dim NoOfRows As Integer
Dim i As Integer, j As Integer
Dim inputrange As Range
Dim outrange As Range


Set inputrange = Application.InputBox("select the filtered range", "Filtered Range", , , , , , 8)

inputrange.Select
Selection.Copy

Set outrange = Application.InputBox("Enter the output worksheet or range", "CopyDayOfWeek", , , , , , 8)

outrange.Select
运行第二步时显示这里出错[ Selection.PasteSpecial Pasta:=xlValues, Operation:=xlNone ]




End Sub
Sub CopyDayOfWeek2()


Dim i As Integer, j As Integer
Dim inputrange As Range
Dim outrange As Range
Dim NoOfRows As Integer
Dim NoOfColumns As Integer

Set inputrange = Application.InputBox("select the filtered range", "Filtered Range ", , , , , , 8)

inputrange.Select
'Selection.SpecialCells(xlCellTypeVisible).Select


NoOfRows = Selection.Rows.Count
NoOfColumns = Selection.Columns.Count

Set outrange = Application.InputBox("Enter the output worksheet or range", "CopyDayOfWeek", , , , , , 8)

outrange.Resize(1, 1).Select

For i = 1 To NoOfRows
For j = 1 To NoOfColumns

Selection.Offset(i - 1, j - 1).Value = inputrange.Resize(1, 1).Offset(i - 1, j - 1).Value

Next j
Next i

End Sub


高手们,求助啊!
DawnPine 2006-06-01
  • 打赏
  • 举报
回复
既然是作业还是自己解决的好
录制个宏看一下
cuiyue4420 2006-06-01
  • 打赏
  • 举报
回复
先复制后粘贴
Application.CutCopyMode = False '复制粘贴
Selection.Copy
ActiveWindow.SmallScroll Down:=12
iTemp = iTemp + 1
sCha1 = sCha1 & iTemp
Range(sCha1).Select
ActiveSheet.Paste
Application.CutCopyMode = False
Arqui 2006-06-01
  • 打赏
  • 举报
回复
粘贴时出错 是你要贴到worksheet去 如果贴到某cell的话就不行
fx_guo 2006-06-01
  • 打赏
  • 举报
回复
参考一下excel2000的帮助文件中的VBAXL9.CHM,中间有许多操作Excel的.

5,139

社区成员

发帖
与我相关
我的任务
社区描述
其他开发语言 Office开发/ VBA
社区管理员
  • Office开发/ VBA社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧