简体   繁体   English

将选择内部颜色索引复制到不同工作表上的相同区域

[英]Copy Selection Interior ColorIndex to same area on different Worksheet

I'm trying to copy the Colorindex of a highlighted selection to a different Worksheet.我正在尝试将突出显示的选择的颜色索引复制到不同的工作表。

I have 4 different Worksheets and on sheet 1 the user is able to colorize the Cells.我有 4 个不同的工作表,在工作表 1 上,用户可以为单元格着色。 Then I want him to be able to select an area of those cells an copy the colors to all other sheets (same location) by clicking a button that triggers my sub "Mark_all".然后我希望他能够通过单击触发我的子“Mark_all”的按钮将 select 区域复制到所有其他工作表(相同位置)。

I'm stuck because "selection" seems to contain the Worksheet on which the selection has been made.我被卡住了,因为“选择”似乎包含进行选择的工作表。

Here is what I tried:这是我尝试过的:

Dim CurCell As Range
Dim ColCurCell As Integer
Dim cWs As Worksheet

Sub Mark_all()
For Each CurCell In Selection
ColCurCell = CurCell.Interior.ColorIndex
    For Each cWs In Application.ActiveWorkbook.Worksheets
    If cWs.Name <> "A Worksheet I DonT want to be changed" Then
    CurCell.Interior.ColorIndex = ColCurCell  '<-- Here I dont know how to combine my CurCell with the other Worksheets
    End If
    Next
Next
End Sub

Thank you:-)谢谢:-)

Use the .Address :使用.Address

For Each cWs In Application.ActiveWorkbook.Worksheets
    If cWs.Name <> "A Worksheet I DonT want to be changed" Then
        cWs.Range(CurCell.Address).Interior.ColorIndex = ColCurCell
    End If
Next

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 两种不同的内部单元格颜色给我相同的colorIndex VBA - Two different interior cell color give me the same colorIndex VBA Excel VBA —三个连续的单元格具有相同的interior.colorindex,但是这三个单元格的范围返回不同的颜色 - Excel VBA — three consecutive cells have the same interior.colorindex, but the range of these three cells returns different colors 单元格的.Interior.ColorIndex值不同于可见值 - Cell's .Interior.ColorIndex Value Different From What Is Visible VBA:使用数组搜索动态数据集条件并基于interior.colorindex进行复制 - VBA: Using an array to search dynamic dataset conditions and copy based on interior.colorindex 在同一工作表的不同位置复制和粘贴表格 - Copy and paste table in different locations in same worksheet 如何更改有条件格式的单元格的内部颜色索引 - How to change the interior colorindex of a conditionally formatted cell 将不同的Excel中的同一工作表复制到一个目标Excel文件中 - Copy same worksheet in different Excel to one destination Excel file 宏 - 将由复选框触发的同一行中的某些单元格复制到不同的工作表 - Macro - Copy CERTAIN Cells in Same Row, Triggered by a Checkbox, to Different Worksheet Exce VBA Interior.ColorIndex增加文件大小 - Exce VBA Interior.ColorIndex increase file size 在用户函数中指定 .Interior.ColorIndex 时出现 VBA 错误 - VBA errors when you specify .Interior.ColorIndex in user function
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM