Excel宏的错误消息 - 从一个单元格复制到另一个单元格

时间:2021-10-05 20:25:52

I got the error message "runtime error '1004' "We can't do that to a merged cell." when I was using the following code:

我收到错误消息“运行时错误'1004'”我们无法对合并的单元格执行此操作。“当我使用以下代码时:

Sub CBCR71Out_Click()
   If ActiveSheet.CheckBoxes("CBCR71Out").Value = 1 Then
      Sheets("7 ELA").Range("CR71Out").Copy _
        Destination:=Worksheets("7 ELA Output").Range("CR7.1")
   Else
      Sheets("7 ELA Output").Range("CR7.1").Value = ""
   End If
End Sub

I am creating an Excel workbook where users select info on one worksheet and it is copied to a second sheet and put into a print friendly format. This particular piece of info goes from 1 cell on the original sheet to a merged 3-cell title on the output sheet.

我正在创建一个Excel工作簿,用户在一个工作表上选择信息,然后将其复制到第二个工作表并放入打印友好格式。这条特殊的信息从原始工作表上的1个单元格到输出表单上的合并3单元格标题。

I'm learning as I go, so I don't know what to do here.

我正在学习,所以我不知道该怎么做。

1 个解决方案

#1


I'm not exactly sure how to do this the way you have, but you could probably change this code:

我不太确定如何以你的方式做到这一点,但你可能会改变这段代码:

 Sheets("7 ELA").Range("CR71Out").Copy _
   Destination:=Worksheets("7 ELA Output").Range("CR7.1")

to this code:

这段代码:

Sheets("7 ELA Output").Range("CR7.1").Value = Sheets("7 ELA").Range("CR71Out").Value

Essentially putting the value to be copied into the print friendly one.

基本上将要复制的值放入打印友好的值中。

#1


I'm not exactly sure how to do this the way you have, but you could probably change this code:

我不太确定如何以你的方式做到这一点,但你可能会改变这段代码:

 Sheets("7 ELA").Range("CR71Out").Copy _
   Destination:=Worksheets("7 ELA Output").Range("CR7.1")

to this code:

这段代码:

Sheets("7 ELA Output").Range("CR7.1").Value = Sheets("7 ELA").Range("CR71Out").Value

Essentially putting the value to be copied into the print friendly one.

基本上将要复制的值放入打印友好的值中。