Thread
:
Copy format based on identical datafields
View Single Post
#
2
Posted to microsoft.public.excel.programming
Claus Busch
external usenet poster
Posts: 3,872
Copy format based on identical datafields
Hi Johan,
Am Tue, 11 Oct 2016 11:06:44 -0700 (PDT) schrieb
:
When push the button start a macro.
Sheet1:
Run a loop from row2 till last.
For each record:
Select the combined tekst in "Column_I + Column_J".
Sheet2:
Search in sheet2 to the indentical combined text in "Column_I + Column_J".
If found:
copy the format of that row in sheet2 from "Column_L till Column_UV"
to the active record in sheet1 to "Column_L till Column_UV".
If not found:
Next row till last one.
try:
Sub CopyFormat()
Dim wsh1 As Worksheet, wsh2 As Worksheet
Dim var1 As Variant, var2 As Variant
Dim i As Long, j As Long
Set wsh1 = Sheets("Sheet1")
Set wsh2 = Sheets("Sheet2")
Application.ScreenUpdating = False
var1 = wsh1.UsedRange
var2 = wsh2.UsedRange
For i = 2 To UBound(var1)
For j = LBound(var2) To UBound(var2)
If var1(i, 9) & var1(i, 10) = var2(j, 9) & var2(j, 10) Then
With wsh2
.Range(.Cells(j, "L"), .Cells(j, "UV")).Copy
wsh1.Cells(i, "L").PasteSpecial xlPasteFormats
End With
Exit For
End If
Next
Next
Application.ScreenUpdating = True
End Sub
Regards
Claus B.
--
Windows10
Office 2016
Reply With Quote
Claus Busch
View Public Profile
Find all posts by Claus Busch