Consulting

Results 1 to 3 of 3

Thread: Solved: Copy the data

  1. #1

    Solved: Copy the data

    I have some data in one excel file and i want to open the another excel file, copy the data in that excel file and then close it again. In short i want to export that data in another excel file.
    Also i want to transpose the data in following manner, for example
    Old excel range A1-D1 to new excel Range A1-A4
    Old excel range A2-D2 to new excel range A5-A8
    Old excel range A3-D3 to new excel range A9-A10
    And so on.....
    Can any body help me ?

  2. #2
    VBAX Mentor
    Joined
    Jul 2012
    Posts
    398
    Location
    [VBA]Public Sub copyrange2()
    Dim wk1 As Workbook, wk2 As Workbook, sh As Worksheet
    Dim sh1 As Worksheet, lng As Long, lRow As Long
    Set wk1 = ThisWorkbook
    Set wk2 = Workbooks.Open(ThisWorkbook.Path & "\yourfile.xlsx")
    Set sh1 = wk1.Worksheets(1)
    Set sh2 = wk2.Worksheets(1)
    sh1.Range("A11").Copy
    sh2.Range("A1").PasteSpecial Transpose:=True
    sh1.Range("A22").Copy
    sh2.Range("A5").PasteSpecial Transpose:=True
    sh1.Range("A33").Copy
    sh2.Range("A9").PasteSpecial Transpose:=True
    Application.CutCopyMode = False
    wk2.Close
    End Sub[/VBA]

  3. #3
    Many Many Thanks

    It worked .......!!!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •