Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 55
Default Copy of coloring format, now in diferent files (change of earlierrecieved code)

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Lock Cell Format - Allow copy and paste of data without format change Chris12InKC Excel Worksheet Functions 2 May 9th 23 07:42 PM
Compare two Worksheet and copy the diferent rows to other CC Excel Discussion (Misc queries) 0 December 10th 08 04:48 PM
Change all files format in folder K[_2_] Excel Programming 2 September 5th 08 09:49 PM
how to copy a sheet to diferent workbook. no paste aidan Excel Programming 1 November 14th 06 09:59 PM
I need to change this code to copy All files the "customdoc" folde macrowriter Excel Programming 5 December 15th 05 09:56 PM


All times are GMT +1. The time now is 11:26 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"