Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello :)
Earlier received solutions works well, Thanks for it (see code below). But I'm struckling now to change the code because the data is not longer in the same file as it was earlier. Now it is: wrkb1 should be the ActiveWorkbook. wsh1 is always the sheetname "Data" in wrkb1. wrkb2 is an open workbook with always the name "ColorData.xlsm" wsh2 is always the sheetname "ColorFields" in wrkb2. Info: In this workbook/sheet are the colored fields that has to be copieed to the records in wrkb1/wsh1. Below code refered now only to two sheets in the same file. Can somebody help me out to include in this code the reference to the other workbook. regards, Johan. ----------------------------------------------------------------------------- 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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Lock Cell Format - Allow copy and paste of data without format change | Excel Worksheet Functions | |||
Compare two Worksheet and copy the diferent rows to other | Excel Discussion (Misc queries) | |||
Change all files format in folder | Excel Programming | |||
how to copy a sheet to diferent workbook. no paste | Excel Programming | |||
I need to change this code to copy All files the "customdoc" folde | Excel Programming |