0

I want to copy cell range (A2:BG2) from Workbook A, Sheet 2 to Active Workbook B, Active Sheet 3 range (A1:BG1).

This is what I came up with.

Sub Macro6()
'
' Macro6 Macro
'

'
    ActiveCell.Rows("1:1").EntireRow.Select
    Windows("Bollore - kopregels importeren Bollore invoice soorten.xlsx").Activate
    ActiveCell.Offset(-11, 0).Rows("1:1").EntireRow.Select
    ActiveCell.Offset(-11, -4).Range("A1").Activate
    Selection.Copy
    Windows("Personal.xlsb").Activate
    Selection.Insert Shift:=xlDown
    ActiveCell.Offset(5, 12).Range("A1").Select
    ActiveWindow.ScrollColumn = 2
    ActiveWindow.ScrollColumn = 3
    ActiveWindow.ScrollColumn = 4
Community
  • 1
  • 1
Tim
  • 1
  • 5
    Welcome to Stack Overflow! We are here to help with specific programming questions you have, once you've made an honest effort and are stuck. I'd start with the macro recorder or research other questions here on SO, try modifying the code, and if you're stuck come back with your specific issue. – BigBen Aug 22 '18 at 14:57
  • It works as long as I stay on the same workbook and sheet. But I want it to be universal so I can paste the range in the active sheet I have open. I know it has something to do with the "Personal.xlbs" but that's where I get stuck – Tim Aug 22 '18 at 15:19
  • 4
    You can actually [edit](https://stackoverflow.com/posts/51969654/edit) your post with that code, as opposed to posting it in a comment. – BigBen Aug 22 '18 at 15:21
  • Possible duplicate of [Copy from one workbook and paste into another](https://stackoverflow.com/questions/19351832/copy-from-one-workbook-and-paste-into-another) – Alexander Aug 22 '18 at 17:00
  • Welcome to Stack Overflow! Please take the [tour](https://stackoverflow.com/tour) and read through the [help center](http://stackoverflow.com/help), in particular how to ask. Your best bet here is to do your research, search for related topics on SO, and give it a go. After doing more research and searching, post a [Minimal, Complete, and Verifiable example](https://stackoverflow.com/help/mcve) of your attempt and say specifically where you're stuck, which can help you get better answers. – help-info.de Aug 22 '18 at 17:22

1 Answers1

0

Hope this will help you

Sheets("Sheet2").Range("A2:BG2").Copy Destination:=Sheets("Sheet3").Range("A1:BG1")

Or you can use

    'Copy the data
    Sheets("Sheet2").Range("A2:BG2").Copy
    'Activate the destination worksheet
    Sheets("Sheet3").Activate
    'Select the target range
    Range("A1:BG1").Select
    'Paste in the target destination
    ActiveSheet.Paste       
    Application.CutCopyMode = False
Dinu Kuruppu
  • 165
  • 1
  • 15