English 中文(简体)
其他工作手册的定本和本工作书的复印件
原标题:Find value in other sheet of other workbook and copy to the sheet of current work book
  • 时间:2011-10-24 15:39:42
  •  标签:
  • vba

I have 2 sheets in 2 different work book. a) Workbook(A).Sheets("A") b)Workbook(B).Sheets("B")

Sheet A in workbook A is destination file. Sheet B in Workbook B is source file.

用户名B(开张B)在表A中,然后从表B中找到高于参考值的数值。 如果发现价值,将立即复制并贴在A(工作手册b)上。 然后回到表B,以找到随后的价值(大于参考价值)。 这一进程一直持续到符合某些标准。

I manage to find the value in loop, but i have to paste the value into sheet B, then copy to sheet A. For sure, user has to click the message whether to save sheet B. Below is the code written. Pls enlighten me.

Dim VerR As Workbook
Dim VerRDest As Worksheet
Dim VerRMaxR As Range

Application.ScreenUpdating = False
XLS = Cells(16, 5)
Workbooks(XLS).Activate

Sheets("ROLLER").Select
Path = Cells(18, 5)
NoR = Cells(17, 5)
Workbooks.Open Filename:=Path

Set VerR = Workbooks(XLS)
Sheets("Stat_1").Select        
y = 3
i = 4
Do While (Cells(i, 1) <> "")
    i = i + 1
Loop

m2 = i - 1
For x = 4 To m2
    If (cells(x,2)>5) Then
        y = y + 1
        TF = True
        If TF Then
            Cells(y, 6) = Cells(x + 1, 1)
            Cells(y, 5) = Cells(x + 1, 2)
        End If
    End If
Next x

Set VerMax1 = ActiveSheet.Range(Cells(4, 5), Cells(y, 6))
VerMax1.Copy
ActiveWorkbook.Close

Set VerRDest = VerR.Worksheets("ROLLER")
Set VerRMaxR = VerRDest.Range(Cells(4, 3), Cells(y, 4))
VerRMaxR.PasteSpecial , Paste:=xlPasteValues

我的目标是,在不影响来源工作手册的情况下,保持价值。 Pls帮助。 感谢。 我确实赞赏你的想法。 我是最后的。

问题回答
dim r1 as range, r2 as range

r1.copy r2

r1.copy
r2.pastespecial ....




相关问题
Handling no results for docmd.applyfilter

I have an Access app where I use search functionality. I have a TextBox and a Search Button on the form, and it does a wildcard search of whatever the user enters in the TextBox, and displays the ...

Outlook 2007 CommandBarControl.Execute won t work

I recently switched to Outlook 2007 and noticed that my VBA-macros won t work. I use the following code to open a new appointment-item (and fill it automatically). It worked perfect in Outlook 2003, ...

Connecting to Oracle 10g with ODBC from Excel VBA

The following code works. the connection opens fine but recordset.recordCount always returns -1 when there is data in the table. ANd If I try to call any methods/properties on recordset it crashes ...

MS Access: list macro from VBA

I have to deal with a few macros (not VBA) in an inherited Access application. In order to document them, I would like to print or list the actions in those macros, but I am very dissatisfied by ...

热门标签