图片将使一切都有意义。但我只是试图将“作者信息:”单元格下方的文本复制到另一个单元格位置。这对于一些人来说并不难,因为它只是一个简单的复制和粘贴,但我需要搜索整个工作表并从“作者信息:”下面的第一个单元格中提取所有信息。此时有数千个条目..
屏幕截图Dropbox链接:https://www.dropbox.com/s/nbyg8lkay3c5c9s/Screenshot%202013-12-27%2016.32.38.png
任何帮助都会很棒!
答案 0 :(得分:1)
为方便起见,请尝试以下方法。
这应该是一种快速而肮脏的方法来完成它。
答案 1 :(得分:1)
试试这段代码:
Sub copyAuthorInfo()
Dim src As Worksheet, tgt As Worksheet
Dim irows As Long
Dim rrows As Long
Set src = ThisWorkbook.Sheets("Sheet1") ' this is the sheet with the original data
Set tgt = ThisWorkbook.Sheets("Sheet2") ' author info will be copied into this sheet
irows = src.UsedRange.Rows.Count ' count the number of used rows in sheet 1
rrows = 1 'row counter for the target sheet
For i = 1 To irows
If Cells(i, 1).Value = "Author information:" Then 'make sure to adjust the search text
' copying columns A to C. Change the 3 in the following line to copy more columns.
Range(Cells(i + 1, 1), Cells(i + 1, 3)).Copy tgt.Range("A" & rrows)
rrows = rrows + 1
End If
Next
End Sub
要运行代码,您需要使用Alt-F11或首选方法打开Visual Basic编辑器(VBE)。使用Insert>模块化并粘贴代码。当光标位于代码中的某个位置时,您可以通过按F5来运行代码。
您已使用OSX标记。这是否意味着你使用Mac?您还使用Excel 2007和2010进行了标记。代码可以正常运行,但不适用于Excel 2008 for Mac,因为它不支持VBA。