繁体   English   中英

我的粘贴功能不起作用,我不知道为什么

[英]My Paste function isn't working and I don't know why

我正在尝试将从主列表中选择的条目复制到不同的工作表。 这个想法是它在没​​有详细信息的情况下列出了一个浓缩的名字列表。 看看我选择了什么。 复制选定的报名表并将其粘贴到新位置以生成仅包含我需要的报名表的列表。 我无法判断循环是否正常工作,因为最后的粘贴功能不起作用。

   Sub BidList()


'Sets unique terms used throught this code
  Dim wQuick As Worksheet, wMaster As Worksheet
  Dim BlankFound As Boolean
  Dim x As Long, n As Long, y As Long
  Dim firstrow As Long, pasterow As Long, lastrow As Long, PasteCell As String, MyRange As String

 'Turns off Screen updating to save memory
  Application.ScreenUpdating = False


'Store an initial value for "x" effectively starting the macro at C4 after the +1 in the next step
   x = 3
   n = 0
   y = 0

  Set wQuick = ThisWorkbook.Sheets("Quick Reference")
  Set wMaster = ThisWorkbook.Sheets("MASTER")
  BlankFound = False

'Loop until x equals 600
  Do While BlankFound = False
    x = x + 1
    n = n + 1
    If Trim(wQuick.Cells(x, "B").Value) = "" Then Exit Do




'If there is a 1 in the Boolean column then ...
    If Trim(wQuick.Cells(x, "C").Value) = "1" Then

 'Move the y value so that the template is pasted in the appropriate place
    y = y + 1


'Copy the appropriate form from wMaster
    firstrow = (n * 9) + 18
    lastrow = (n * 9) + 27

    Let MyRange = "A" & firstrow & ":" & "K" & lastrow

    wMaster.Range(MyRange).Copy

'Select the next place for the form to be pasted on wQuick

    pasterow = (y * 9) - 5

     Let PasteCell = "F" & "," & pasterow
     wQuick.Cells(PasteCell).Paste


    End If



  Loop


  Application.ScreenUpdating = True
End Sub

请避免在 Excel 中复制粘贴,最好使用如下所示的 for 循环:

# keep track of MyRange.Row and MyRange.Column
For Each cell in wMaster.Range(MyRange):
  wQuick.Cells(<Starting point>).Offset(<take the cell coordinates, based on MyRange.Row and/or MyRange.Column>).Value = cell.Value
Next

暂无
暂无

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

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