Hello Every body
I have written the program which copy the green range from the other workbook to the master or current workbook if and only if the cell of the master workbook is green now the problem that i am facing is that it copy the green range to all worksheets which contains the green cells in the master workbook i just only want to copy the range to one worksheet can any body fix this problem.
Code
Sub abc()
Dim rn As Range
Dim wb1 As Workbook
Dim wb2
Dim wbslave As Workbook
Dim ws As Worksheet
Set wb1 = ActiveWorkbook 'Current Workbook
ThisWorkbook.Worksheets("Tabelle1").Activate
Application.ScreenUpdating = False
MsgBox "Please choose the slave workbook"
wb2 = Application.GetOpenFilename(Title:="Please choose the slave file")
If wb2 = False Then GoTo finish
Set wbslave = Workbooks.Open(wb2)
Set wbslave = ActiveWorkbook 'other workbook from where the data must be choosen
For Each ws In wb1.Worksheets ' i think here is the problem i want to select only one worksheet
For Each rn In ws.UsedRange.Cells 'For Each rn In ActiveSheet.UsedRange.Cells
If rn.Interior.ColorIndex = 35 Then rn.Value = wbslave.Sheets("Hardcopy").Range(rn.Address).Value
'wb1.Sheets("Tabelle1").Range(rn.Address).Value
Next rn
Next
finish:
Set wbslave = Nothing
Application.ScreenUpdating = True
Set rn = Nothing
End Sub
Display More