+ Reply to Thread
Results 1 to 3 of 3

Create a new file and copy a row from another file

  1. #1
    Registered User
    Join Date
    03-31-2013
    Location
    Washigton DC
    MS-Off Ver
    Excel 2010
    Posts
    7

    Create a new file and copy a row from another file

    Hello: I am new here and also a new Excel MAcro creator. I was trying to create annew file and them copy a row from another file to the new file, but it does not work. It worked individually, but not combined. Please help me.


    Sub Test1()

    Const strPath As String = "E:\TPE-10\MPO-Database\Nazrul\"

    Dim strFileName As String
    Dim wbNew As Workbook

    strFileName = InputBox("Please enter file name", "Create new file")
    If strFileName = vbNullString Then Exit Sub

    Set wbNew = Workbooks.Add
    wbNew.SaveAs Filename:=(strPath & strFileName), FileFormat:=xlNormal

    ' This command will copy A1:AA1 cells from UZA-MPO worksheet to Sheet3 at A3:AA3 location
    ' Workbooks("Macro-test.xlsm").Worksheets("UZA-MPO").Range("A1:AA1").Copy Worksheets("Sheet3").Range("A3:AA3")

    ' The following lines will also do the same thing
    Workbooks("Macro-test.xlsm").Worksheets("UZA-MPO").Range("A1:AA1").Select
    Selection.Copy

    Workbooks("Nazrul.xls").Worksheets("Sheet1").Activate
    Range("A6:AA6").Select
    ActiveSheet.Paste

    ' Worksheet
    ' This command will clear cells C2:C12 in UZA-MPO worksheet

    End Sub

  2. #2
    Forum Contributor
    Join Date
    12-31-2012
    Location
    Jhang, Pakistan
    MS-Off Ver
    Excel 2010
    Posts
    250

    Re: Create a new file and copy a row from another file

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    03-31-2013
    Location
    Washigton DC
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Create a new file and copy a row from another file

    Thank you very much; it worked!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1