我的代码遇到麻烦: 事情就是这样,如果H列=“是”,则将单元格内容从“ A”行复制到“ A”行的另一张纸上,但要从第一行开始。
问题是: 我想将内容粘贴到单元格“ A7”中标头之后的第一行,而不粘贴到满足条件的相应行中。 另外,如果有一种方法可以避免在复制粘贴后将行之间的空白单元格组织起来。
Option Explicit
Private Sub CommandButton1_Click()
'submacro which copies data over columns
Dim lastRow As Long, i As Long
'determine last row in column H
lastRow = Cells(Rows.Count, "H").End(xlUp).Row
For i = 1 To lastRow
'if Yes in H then copy from cell B in OFCE to cell B in DASHBOARD in current row
If Worksheets("OFCE").Cells(i, "H").Value = "Yes" Then
'To paste from Dashboard tab to OFCE tab
Worksheets("Dashboard").Cells(i, "A").Value = Worksheets("OFCE").Cells(i, "A").Value
End If
Next
End Sub
此后,我不仅要转移一行,还要转移许多其他行。
答案 0 :(得分:0)
我不确定我是否完全了解您的需求,但这可能会有所帮助:
type AsyncResultBuilder() =
member __.ReturnFrom vRA : Async<Result<'v , 'm>> = vRA
member __.ReturnFrom vR : Async<Result<'v , 'm>> = AsyncResult.rtnR vR
member __.Return v : Async<Result<'v , 'm>> = AsyncResult.rtn v
member __.Zero () : Async<Result<unit, 'm>> = AsyncResult.rtn ()
member __.Bind (vRA, fRA) : Async<Result<'b , 'm>> = AsyncResult.bind fRA vRA
member __.Bind (vR , fRA) : Async<Result<'b , 'm>> = AsyncResult.bind fRA (vR |> AsyncResult.rtnR)
member __.Combine (vRA, fRA) : Async<Result<'b , 'm>> = AsyncResult.bind fRA vRA
member __.Combine (vR , fRA) : Async<Result<'b , 'm>> = AsyncResult.bind fRA (vR |> AsyncResult.rtnR)
member __.Delay fRA = fRA
member __.Run fRA = AsyncResult.rtn () |> AsyncResult.bind fRA
member __.TryWith (fRA , hnd) : Async<Result<'a , 'm>> = async { try return! fRA() with e -> return! hnd e }
member __.TryFinally(fRA , fn ) : Async<Result<'a , 'm>> = async { try return! fRA() finally fn () }
member __.Using(resource , fRA) : Async<Result<'a , 'm>> = async.Using(resource, fRA)
member __.While (guard , fRA) : Async<Result<unit, 'a>> = AsyncResult.whileLoop guard fRA
member th.For (s: 'a seq, fRA) : Async<Result<unit, 'b>> = th.Using(s.GetEnumerator (), fun enum ->
th.While(enum.MoveNext,
th.Delay(fun () -> fRA enum.Current)))
let asyncResult = AsyncResultBuilder()
[<AutoOpen>]
module Extensions =
type AsyncResultBuilder with
member __.ReturnFrom (vA: Async<'a> ) : Async<Result<'a, 'b>> = Async.map Ok vA
member __.Bind (vA: Async<'a>, fRA) : Async<Result<'b, 'c>> = AsyncResult.bind fRA (Async.map Ok vA)
member __.Combine (vA: Async<'a>, fRA) : Async<Result<'b, 'c>> = AsyncResult.bind fRA (Async.map Ok vA)
答案 1 :(得分:0)
按钮更新将运行您@ Error1004的代码,但现在我不仅需要传输,而且还需要检查和更新传输的数据,而无需重复输入,而只需添加符合条件的新数据,而是将其再次复制到从下面的图像中可以看到以下行:数据来自OFCE表,第二行是复制和粘贴数据。