Hello all,
I have a table with the columns: id, company and year, eg:
2 Dell 1996
2 Microsoft 1999
5 Apple 1997
5 Oracle 1999
5 Amazon 2000
I want to look in this table for a certain id and a certain year (some ids show up multiple times with multiple companies and years, I want hte first instance of an id and year match), and then print the company in the appropriate cell in another 2d table where the left column is just IDs and the row at the top is years.
1995 1996 1997 1998 1999 2000
2 Dell Microsoft
5 Apple Oracle Amazon
I have done this successfully using the following function, but now I also want it to return the color of the cell, not just its value.
---
Function PrintCompany(ID As Long, Year As Integer, cells As Range)
Dim Pos As Range, count As Integer
count = 1
Set Pos = cells(1, 1)
Do While (count <= cells.Rows.count)
PrintCompany = ""
If (ID = Pos.Value And Pos.Offset(0, 2).Value = Year) Then
PrintCompany = Pos.Offset(0, 1).Value
'ActiveCell.Interior.ColorIndex = pos.Offet(0, 1).Interior.ColorIndex <- not working
'currentcell.Interior.Color = pos.Offset(0, 1).Interior.Color <- not working
Exit Do
Else: PrintCompany = ""
End If
count = count + 1
Set Pos = cells(count, 1)
Loop
End Function
--------
I have tried calling a sub from the function to do just that but I don't know how to do it right. I have tried all sorts of other things to no avail. Any help would be appreciated.
Please edit your post to add CODE tags around your code. Instructions for doing so can be found in the Forum Rules, for which there is a link in my signature below.
This is a duplicate post and as such does not comply with Rule 5 of our forum rules. This thread will now be closed, you may continue in your other thread.
http://www.excelforum.com/excel-gene...and-color.html
Thread Closed.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks