
###前提・実現したいこと
ExcelVBAでfind関数を使って、見つかったセルとその横にあるセルの値を配列で取得し別シートに張り付ける際に、そのセルの背景色も取得して貼り付けたいと思っています。
###発生している問題・エラーメッセージ
セルの値は配列で取得でき、別シートに張り付けることができたのですが
`そのセルの背景色の取得と張り付け方が全然わかりません。
よろしくお願いします。
###該当のソースコード
VBA Sub Depomanage() Application.EnableEvents = False Application.Calculation = xlCalculationManual Application.ScreenUpdating = False Dim FoundCell As Range, FirstCell As Range, Target As Range Dim cnt As Long Dim kensaku As String Dim a(700) As Range Dim iFind As Integer Dim ws1 As Worksheet Dim ws2 As Worksheet Dim ws3 As Worksheet Set ws1 = Worksheets("test") Set ws2 = Worksheets("test1") Set ws3 = Worksheets("test2") iFind = 0 For cnt = 2 To ws1.Cells(Rows.Count, "A").End(xlUp).Row DoEvents kensaku = ws1.Cells(cnt, 1).Value ws2.Select Set FoundCell = ws2.Columns("D:D").Find(What:=kensaku, SearchFormat:=True) If FoundCell Is Nothing Then '見つからなかった処理 ws1.Cells(cnt, 1).Interior.ColorIndex = 3 ws1.Cells(cnt, 1).Offset(0, 3) = 0 GoTo YES_TASK Else Set FirstCell = FoundCell '見つかった処理 ws1.Cells(cnt, 1).Interior.ColorIndex = 6 End If Do Set FoundCell = Cells.FindNext(FoundCell) If FoundCell.Address = FirstCell.Address Then Set a(iFind) = Range(FoundCell.Offset(0, -3), FoundCell.Offset(0, 2)) FoundCell.Offset(0, 7) = 1 iFind = iFind + 1 Exit Do Else '重複処理 ws1.Cells(cnt, 1).Interior.ColorIndex = 4 ws1.Cells(cnt, 1).Offset(0, 3) = 2 End If Loop YES_TASK: Next cnt '見つかったセルを別シートに...背景色がない For i = 0 To 700 If a(i) Is Nothing Then Exit For Line = ws3.Cells(Rows.Count, "A").End(xlUp).Row ws3.Select Range(Cells(Line + 1, "A"), Cells(Line + 1, "F")).Value2 = a(i).Value2 Next Application.EnableEvents = True Application.Calculation = xlCalculationAutomatic Application.ScreenUpdating = True End Sub
###試したこと
findで見つかったセルをcopyして張り付けてみたのですが
処理に時間がかかってしまうため、断念しました。
###補足情報(言語/FW/ツール等のバージョンなど)
Excel 2013

回答3件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
退会済みユーザー
2017/08/04 05:18