简体   繁体   中英

Copy and Paste one Cell at a time from a list to another sheet

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

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"

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"

在此处输入图片说明

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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