• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Fetching value of Highlighted Cell

ananthram

New Member
Hi All,


Please help me with below find, which has Highlighted cells like option A, B, C & D. so when Option D is highlighted i need the Cell Value of it in Column Answer Key. same follows to each and every rows.


https://www.box.com/s/xf8h8qujh7mnsjxclw6n
 
Hi Ananth Ram ,


Try this :

[pre]
Code:
Public Sub Answer_Key()
Dim COLORLESS As Long
COLORLESS = RGB(255, 255, 255)

Dim wrk_range As Range
Set wrk_range = Range("A2:D36")

For Each cell In wrk_range
If cell.Interior.Color <> COLORLESS Then
cell.Offset(0, Columns("E").Column - cell.Column).Value = cell
End If
Next
Columns("E").EntireColumn.AutoFit
End Sub
[/pre]
Narayan
 
Sir,


Thank you but what i need is the option ID, that is if option D is highlighted i need D as answer key. same follows to other rows
 
Hi Ananth Ram ,


Try this :

[pre]
Code:
Public Sub Answer_Key()
Dim COLORLESS As Long
COLORLESS = RGB(255, 255, 255)

Dim Options_Array() As Variant
Options_Array = Range("A1:D1").Value

Dim wrk_range As Range
Set wrk_range = Range("A2:D36")

For Each cell In wrk_range
If cell.Interior.Color <> COLORLESS Then
Cells(cell.Row, "E").Value = Options_Array(1, cell.Column)
End If
Next
Columns("E").EntireColumn.AutoFit
End Sub
[/pre]
Narayan
 
Back
Top