@WillDM73
This is from a recent post where data is copied between workbooks that are both open.
I am sure you can go through it and get an idea of what you asked for.
Sub Workbook_To_Workbook_Both_Open()
Dim sh1 As Worksheet, sh2 As Worksheet
Dim wb1 As Workbook, wb2 As Workbook
Dim lr As Long, lc As Long
Set wb1 = ThisWorkbook
Set sh1 = wb1.Sheets("Expenses")
On Error Resume Next
Set wb2 = Workbooks(wb1.Sheets("Inputs").Range("B2").Value) '<----- here the workbook name is in a cell (B2)
If wb2 Is Nothing Then MsgBox "Workbook is not open Please open it first.": Exit Sub
Set sh2 = wb2.Sheets(wb1.Sheets("Inputs").Range("B3").Value) '<----- here the worksheet name is in a cell (B3)
lr = sh2.Cells.Find("*", , , , xlByRows, xlPrevious).Row '<----- find the last used row
lc = sh2.Cells.Find("*", , , , xlByColumns, xlPrevious).Column '<----- find the last used column
Application.ScreenUpdating = False
sh2.Range("A1").Resize(lr, lc).Copy '<---- Copy from A1 to the last used row and column
'This line for a one time paste only
'sh1.Range("A1").PasteSpecial Paste:=xlPasteAll 'or xlPasteValues or whatever. See the help file under PasteSpecial - xlPasteType
'This line for multiple pastes into the same sheet.
sh1.Cells(Rows.Count, 1).End(xlUp).Offset(1).PasteSpecial Paste:=xlPasteAll
Application.CutCopyMode = False '<----- Clear "marching ants" and clear clipboard
Application.ScreenUpdating = True
End Sub
Bookmarks