简体   繁体   English

使用公式复制范围内特定值的单元格

[英]Copying Cells with a Specific Value in a Range using a Formula

I am trying to import and maintain a list in excel of all taken fantasy football players in my fantasy league and their avg pts per week. 我正在尝试导入并维护一份我的幻想联盟中所有已采取的幻想足球运动员及其每周平均得分的列表,并且要优于他们。 I can get this information from yahoo at 25 players per page, so I have set up an excel workbook with each page importing a weblink into excel with 25 players (10 pages total) 我可以每页25个播放器的方式从yahoo获得此信息,因此我已经建立了一个excel工作簿,每个页面都将一个具有25个播放器的网络链接导入excel(共10页)

The idea is that every week I can simply refresh all of the pages into excel and then have another sheet in the same workbook that goes through all of the worksheets and puts them into a nice list which I can manipulate and play with. 我的想法是,每周我都可以简单地将所有页面刷新到excel,然后在同一工作簿中有另一个工作表浏览所有工作表,并将它们放入一个不错的列表中,以便我操作和使用。 It would essentially be: 本质上是:

Player Name | Position | Team Name | AVG PTS

Unfortunately the information imported is a little variable so I cannot specifically reference absolute cells. 不幸的是,导入的信息是一个很小的变量,因此我无法具体引用绝对单元格。 This is because there may or may not be an extra row between players with their injury status. 这是因为球员之间的受伤状态可能会或可能不会额外发生。

What I do know is that the player name is in column b, starting within the range B160 and ending at a maximum B250. 我所知道的是,玩家名称在b列中,开始于B160范围,结束于最大B250。 Each player's name in column b can be isolated with a ctrl+f for " - " b列中每个玩家的名字都可以使用ctrl + f分隔“-”

What I want to do is set up a formula on a separate sheet in the workbook that will: 我想做的是在工作簿的另一张纸上设置一个公式,该公式将:

  1. search this range on the worksheets with the imported data, 在工作表中使用导入的数据搜索此范围,
  2. find all strings with a " - " in this range 查找此范围内所有带有“-”的字符串
  3. copy/return full string of cell and nothing else 复制/返回完整的单元串,别无其他

I'm not sure if this is possible with a formula, and I haven't had any luck looking at other posts on here. 我不确定公式是否可以实现这一目标,而且我在这里查看其他帖子也没有运气。

Here is a link to a truncated version of what I'm doing using google docs (I feel like people would feel funny downloading some random excel file: 这是我使用google docs所做操作的截短版本的链接(我觉得人们下载一些随机的excel文件会很有趣:

https://docs.google.com/spreadsheet/ccc?key=0AvLwUKmn33T6dHhGcEVwWC1KdXpMblJoRGJzMlNWWlE&usp=sharing https://docs.google.com/spreadsheet/ccc?key=0AvLwUKmn33T6dHhGcEVwWC1KdXpMblJoRGJzMlNWWlE&usp=sharing

An easy way if you just have a couple of sheets, is to filter the column, and type in " - " (without quotes) in filter search. 如果只有几张纸,一种简单的方法是过滤该列,然后在过滤器搜索中键入“-”(不带引号)。 This works for 2007+. 适用于2007年以上的版本。 Copy and paste the visible cells only to your main workbook. 仅将可见单元格复制并粘贴到您的主工作簿中。

You could also use VBA to do this: 您也可以使用VBA来执行此操作:

Dim sMain As String
Dim sImported As String, lLen As Long
Dim sStart As String
sMain = "ALL TAKEN PLAYERS AVG" 'name of your main sheet
sMainCol = "A" 'column your player names will go in
sImported = "Imported Data " 'string that player sheets start with
lLen = Len(sImported)
sStart = "B160" 'starting cell for imported data

Dim ws As Worksheet
Dim rPlayers As Range, cell As Range
Dim counter As Long

counter = 5 'starting row to fill out players

For Each ws In Worksheets
    If Left(ws.Name, lLen) = sImported Then
        ws.Activate
        Set rPlayers = Range(Range(sStart), Range(sStart).End(xlDown))
        For Each cell In rPlayers
            If InStr(1, cell.Value, " - ") > 0 Then
                Sheets(sMain).Range(sMainCol & counter).Value = cell.Value
                counter = counter + 1
            End If
        Next cell
    End If
Next ws

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

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