我要求帮助比较不同时间点实验中的基因表达值,用Excel或VBA进行比较然后生成报告表。每张表(时间点)包含两列:基因ID和值,基因ID在每张表中可能不相同(时间点:1H,4H和8H ......等)。在报告表(表4)中,我想拥有所有基因ID(第1列)和每个时间点的值(第2列,第3列,第4列)。因此,最终的表(表4)将包括从每个表到列1的所有Gene ID,sheet1(value1),sheet2(value2)和sheet3(value3)的表达式值将在column2,column3和column4中的表4。我使用excel的“vlookup”可以在比较/查找ID之后将表达式值添加到sheet4中,但我不知道如何为所有工作表添加GeneID。
看起来像:
Sheet1(1H):
(标题)GeneID,Value1
Eco,2;
Xmo,4;
Sheet2(4H):
(标题)GeneID,Value2
Eco,6;
嗯,8;
Sheet3(24H):
(标题)GeneID,Value3
Xmo,10;
阿玛,12;
最终的表4(摘要):
(标题)GeneID,Value1,Value2,Value3
Eco,2,6,(空白);
Xmo,4,(空白),6;
嗯,(空白),8,(空白);
Ana,(空白),(空白),12;
答案 0 :(得分:1)
我认为最快的方法可能是使用 Data | Consolidate 命令显示设置:
答案 1 :(得分:0)
你可以用ADO和Excel做很多事情。我们说您的工作表名称是1小时,4小时和24小时。
''http://support.microsoft.com/kb/257819
Dim cn As Object
Dim rs As Object
Dim strFile As String
Dim strCon As String
Dim strSQL As String
Dim s As String
Dim i As Integer, j As Integer
''This is not the best way to refer to the workbook
''you want, but it is very convenient for notes
''It is probably best to use the name of the workbook.
strFile = ActiveWorkbook.FullName
''HDR=Yes, the names in the first row of the range
''are used as field (column) names.
''
''This is the ACE / Excel 2007/10 connection string, you can get more
''here : http://www.connectionstrings.com/excel
strCon = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & strFile _
& ";Extended Properties=""Excel 12.0 Xml;HDR=YES"";"
''Late binding, so no reference is needed
Set cn = CreateObject("ADODB.Connection")
Set rs = CreateObject("ADODB.Recordset")
cn.Open strCon
strSQL = "TRANSFORM Sum(ValX) As SumVal " _
& "SELECT GeneID FROM ( " _
& "SELECT GeneID, '01Hour' As TimeX, Value1 As ValX " _
& "FROM [1Hour$] " _
& "UNION ALL " _
& "SELECT GeneID, '04Hour' As TimeX, Value2 As ValX " _
& "FROM [4Hour$] " _
& "UNION ALL " _
& "SELECT GeneID, '24Hour' As TimeX, Value3 As ValX " _
& "FROM [24Hour$] ) t " _
& "GROUP BY GeneID " _
& "PIVOT TimeX"
rs.Open strSQL, cn, 3, 3
''Pick a suitable empty worksheet for the results
With Worksheets("Sheet4")
For i = 0 To rs.Fields.Count - 1
.Cells(1, i + 1) = rs.Fields(i).Name
Next
.Cells(2, 1).CopyFromRecordset rs
End With
''Tidy up
rs.Close
Set rs = Nothing
cn.Close
Set cn = Nothing
可以使用Jet / ACE SQL。
Fundamental Microsoft Jet SQL for Access 2000
Intermediate Microsoft Jet SQL for Access 2000
Advanced Microsoft Jet SQL for Access 2000