+ Reply to Thread
Results 1 to 2 of 2

VBA code for pasting values into a workbook beginning with the next row

Hybrid View

  1. #1
    Registered User
    Join Date
    09-04-2012
    Location
    Oklahoma City, OK
    MS-Off Ver
    Excel 2010
    Posts
    9

    VBA code for pasting values into a workbook beginning with the next row

    I have the following code that is meant to copy and paste certain values from one workbook to another, but I need the macro to make a list in the workbook being pasted into by always pasting on the next available line. I keep getting an "Object Required" error with my current code and I can't figure out what to do.

    Sub Save_Ratings()
    '
    ' Save_Ratings Macro
    '
    
    '
        ChDir "F:\FSG\DANA\Muni Offering Sheet Ratings"
        Workbooks.Open Filename:= _
            "F:\FSG\DANA\Muni Offering Sheet Ratings\Muni Offering Sheet Ratings.xlsx"
        Windows("Copy of Muni Offering Sheet-with True Yield 2.xlsm").Activate
        Range("D3").Select
        Selection.Copy
        Windows("Muni Offering Sheet Ratings.xlsx").Activate
        Worksheets("Ratings").Activate
        lastRow = ActiveSheet.Cells(Row.Count, "A").End(xlUp).Row
        ActiveSheet.Range("A" & lastRow + 1).Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
        Windows("Copy of Muni Offering Sheet-with True Yield 2.xlsm").Activate
        Sheets("Muni").Select
        Range("N24:T25").Select
        Application.CutCopyMode = False
        Selection.Copy
        Windows("Muni Offering Sheet Ratings.xlsx").Activate
        lastRow = ActiveSheet.Cells(Row.Count, "A").End(xlUp).Row
        ActiveSheet.Range("A" & lastRow + 1).Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
        Windows("Copy of Muni Offering Sheet-with True Yield 2.xlsm").Activate
        Range("N30:T31").Select
        Application.CutCopyMode = False
        Selection.Copy
        Windows("Muni Offering Sheet Ratings.xlsx").Activate
        lastRow = ActiveSheet.Cells(Row.Count, "A").End(xlUp).Row
        ActiveSheet.Range("A" & lastRow + 1).Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
        Application.CutCopyMode = False
        ActiveWorkbook.Save
        ActiveWindow.Close
        Sheets("MUNI INPUT").Select
        Range("D3").Select
    End Sub
    Any help would be greatly appreciated!

    Thanks!
    Last edited by arlu1201; 06-04-2013 at 02:03 AM. Reason: Use code tags in future.

  2. #2
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: VBA code for pasting values into a workbook beginning with the next row

    You first want to copy D3 from one file to the next available row in column A in file 2? Then copy N24:T25 to the next available row in column A in file 2? Then again copy N30:T31 to the next available row in column A in file 2?
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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