Copy info from cell from one workbook to another if they bought are open

Rolly_Sefu

Board Regular
Joined
Oct 25, 2013
Messages
149
Hello, I have created a code that allows me to copy info from a cell into a workbook that will be opened and then closed.

But now I want to change to code to copy from one open workbook to another open workbook, and I need help.

this is my code

Code:
Sub Macro10()
    txt = ActiveWindow.Caption
    Range("G1") = Range("D6")
    Range("H1") = "=VALUE(R[7]C[-4])"
    Range("H1") = Range("H1")
    If Range("D36") = "training " Then
        Range("I1") = Range("C36")
        Range("J1") = Range("C27")
    Else
        Range("I1") = 0
        Range("J1") = 0
    End If
    'Range("G1:J1").Copy
    Set x = Workbooks.Open("C:\Users\jagerr\Desktop\output2.xlsx")
    Dim LastRow As Long
    LastRow = Workbooks("output2.xlsx").Worksheets("Info").Range("A" & Rows.Count).End(xlUp).Row + 1
    Workbooks("output2.xlsx").Worksheets("info").Range("A" & LastRow & ":" & "D" & LastRow).Value = Workbooks(txt).Worksheets("output").Range("G1:J1").Value
    Application.DisplayAlerts = False
    x.Close SaveChanges:=True
    Application.DisplayAlerts = True
End Sub

Thanks you.
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
Experts may give you a better solution. Until then, the following COPYING CODE may help you.
Code:
 Dim MasterRng  As Range
 Dim DataRng  As Range
 Set MasterRng = Workbooks(txt).Worksheets("output").Range("G1:J1")
 Set DataRng = MasterRng.SpecialCells(xlCellTypeVisible)
 If Not DataRng Is Nothing Then
  DataRng.Copy Workbooks("output2.xlsx").Sheets("info").Range("A" & Lastrow & ":" & "D" & Lastrow)
 End If
I have not tried this.But I have tried a similar one and it works.
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,337
Members
452,636
Latest member
laura12345

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top