View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Dave Dave is offline
external usenet poster
 
Posts: 1,388
Default Return column heading

Hi,
Put this macro into a module and run it.
Answer the questions it asks.
Is the result roughly what you want?

Sub ListSubjects()
Dim Grade As String
Dim A As Integer
Dim B As Integer
Dim C As Integer
Dim D As Integer
Dim E As Integer
A = InputBox("What is the Row Number of the first student?")
B = InputBox("What is the Column Number of the first Subject?" & Chr(10) &
"(A=1, B=2 etc)")
C = InputBox("What is the Row Number or your subject headers?")
D = InputBox("What is the Column Number of your student names?" & Chr(10) &
"(A=1, B=2 etc)")
E = InputBox("What column would you like the results put into?" & Chr(10) &
"(A=1, B=2 etc)")
Grade = InputBox("What grade do you want listed?")
Do Until Cells(A, D) = ""
For i = 1 To 18
If Cells(A, B) = Grade Then Cells(A, E) = Cells(A, 20) & " " & Cells(C, B)
B = B + 1
Next i
B = 2
A = A + 1
Loop
End Sub

You'll have to unwrap any lines that have been wrapped by this newsgroup
format.
Be sure to input Column Numbers when asked (1, 2, 3 etc - not A, B, C etc)
Regards - Dave.