I have this code that I want to use to copy a color:
Sub color_switcher(start_cell As Cells, end_cell As Cells) Dim color As Long color = start_cell.Interior.color end_cell.Interior.color = color End Sub
and here is my test sub:
Im getting the error:Sub test_func() Call color_switcher(Cells(1, 1), Cells(2, 1)) End Sub
user defined type not defined
what am I doing wrong?
thanks, in advance.
Hi
Try using Range not Cells
[CODE]
Sub color_switcher(start_cell As Range, end_cell As Range)
Dim color As Long
color = start_cell.Interior.color
end_cell.Interior.color = color
End Sub
[/CODE
--
Regards
Roger Govier
Microsoft Excel MVP
thanks for the quick reply.
I tried it with range but got the
object _global failed error
Try replacing
withSub color_switcher(start_cell As Cells, end_cell As Cells)
Sub color_switcher(start_cell, end_cell)
and to finish off the switch?
Sub color_switcher(start_cell, end_cell) Dim color1 As Long, color2 As Long color1 = start_cell.Interior.color color2 = end_cell.Interior.color start_cell.Interior.color = color2 end_cell.Interior.color = color1 End Sub
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks