简体   繁体   English

通过Excel工作表解析

[英]Parsing through excel sheet

I have the following excel sheet data that I need to parse out: 我需要解析以下excel工作表数据:

A                         B C                                       D
----------------------------------------------------------------------------------
70 Skill Set                Career Prep Skills      
71 Knowledge Objectives     Something will blah 
72          
73 AR.1                   • blah blah blah. 
74                        • blah blah blah. 
75                        • blah blah blah. 
76                        • blah blah blah. 
77 Performance Objectives   Something will and
78          
79 AR.2                   • blah blah blah. 
80 AR.3                   • blah blah blah. 
81 AR.4                   • blah blah blah.
82 AR.5                   • blah blah blah.
83 AR.6                   • blah blah blah. 
84 AR.7                   • blah blah blah.
85 AR.8                   • blah blah blah.
86 AR.9                   • blah blah blah.
87 AR.10                  • blah blah blah.
88 AR.11                  • blah blah blah.
89 Skill Set                Safety is key
90 Knowledge Objectives     blah blah blah.     
91          
92 AR.12                  • blah blah blah. 
93                        • blah blah blah.
94                        • blah blah blah.

The format that I am needing it in is this: 我需要的格式是这样的:

Skill Set    Career Prep Skills           AR.1    blah blah blah. 
                                                  blah blah blah. 
                                                  blah blah blah. 
                                                  blah blah blah.
                                          AR.2    blah blah blah.
                                          AR.3    blah blah blah.
                                          AR.4    blah blah blah.
                        etc....
Skill Set    Safety is key                AR.12   blah blah blah.
                                                  blah blah blah.
                                                  blah blah blah.

I have the following code: 我有以下代码:

xlsCell = xlsSheet.Range("A1:A200")

For Each oRowRange As Excel.Range In xlsCell.Rows
    For Each oCellRange As Excel.Range In oRowRange.Columns
        Dim theColor = oCellRange.Interior.Color
        Dim colorRGB = (theColor Mod 256) & ", " & ((theColor \ 256) Mod 256) & ", " & (theColor \ 65536)

        If colorRGB = "252, 213, 180" Then
            'find the last row in the spreadsheet:
            lastrow = xlsCell.SpecialCells(Excel.XlCellType.xlCellTypeLastCell).Row
            'Change the range to reflect the last row:
            xlsCell = xlsSheet.Range("A1:A" & lastrow)
            'found first listing (Standard) so save it's text:
            tmpStandard = oCellRange.Text 'a.k.a Skill Set
            'Move on over to see the Cluster Name:
            tmpCluster = oCellRange.Offset(0, 1).Text() 'a.k.a Career Prep Skills
            'Now we need to get the OBJ:
               'a.k.a AR.1
            'Now get paragraph(s):
              'a.k.a blah blah blah.
        End If
    Next
Next

But I am unsure how to go about knowing its a different AR. 但是我不确定如何去了解它的不同AR。 number, etc. 号码等

visual example as above: 上面的视觉示例: 在此处输入图片说明 Any help would be great! 任何帮助将是巨大的!

This is not really an answer, it's more like a comment to provide some ideas on how to identify the cells with "AR" that you are interested in. Hopefully this picture will provide some ideas that you can use: 这并不是一个真正的答案,它更像是一条评论,它提供了一些有关如何识别您感兴趣的带有“ AR”的单元格的想法。希望此图可以提供一些可以使用的想法:

在此处输入图片说明

This seems easy, but before I give example I want to confirm something because your sample data and image don't seem to quite match. 这似乎很容易,但是在我举个例子之前,我想确认一下事情,因为您的样本数据和图像似乎不太匹配。 What do those two lines print? 这两行打印什么?

Debug.Print Range("C70:C94").SpecialCells(xlCellTypeConstants).Address(0, 0)
Debug.Print Range("C70:C94").SpecialCells(xlCellTypeBlanks   ).Address(0, 0)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM