热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

将一个单元格从列表复制并粘贴到另一个工作表-CopyandPasteoneCellatatimefromalisttoanothersheet

iamanovicewhenitcomestoVBAandwouldlikesomehelp.我是VBA的新手,想要一些帮助。Iamtryingtocopyo

i am a novice when it comes to VBA and would like some help.

我是VBA的新手,想要一些帮助。

I am trying to copy one cell at a time from one sheet to to another. The reason for this is because I want to copy one cell (account #) from a list (sheet "List") and paste into a predefined cell is another sheet ("Analysis") and run code that will extract data from a program. i want to then repeat this process for all the account #s in that list until the list ends. The # of accounts in this list will change periodically. Account # will always be entered into Cell "F2"

我试图将一个单元格从一张纸复制到另一张纸。这是因为我想从列表中复制一个单元格(帐户#)(表单“List”)并粘贴到预定义单元格中是另一个工作表(“分析”)并运行将从程序中提取数据的代码。我想对该列表中的所有帐户#s重复此过程,直到列表结束。此列表中的帐户数量将定期更改。帐号#将始终输入单元格“F2”

The code i am using to extract data is,

我用来提取数据的代码是,

Range("F2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False
Application.Run "'Option holding.xls'!SecurityDistribution"

enter image description here

1 个解决方案

#1


0  

Loop through the list and call the macro

循环遍历列表并调用宏

    Sub Do_It()
    Dim Sh As Worksheet, ws As Worksheet
    Dim Rng As Range, LstRw As Long
    Dim F1 As Range, c As Range

    Set Sh = Sheets("Transaction Analysis")
    Set F1 = Sh.Range("F1")
    Set ws = Sheets("List")
    With ws
        LstRw = .Cells(.Rows.Count, "A").End(xlUp).Row
        Set Rng = .Range("A2:A" & LstRw)
        For Each c In Rng.Cells
            F1.Value = c
            MsgBox "Call Macro Here"
        Next c
    End With
End Sub

推荐阅读
author-avatar
轩风羽_609
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有