+ Reply to Thread
Results 1 to 18 of 18

VBA code for formula

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Washington DC
    MS-Off Ver
    Excel 2007
    Posts
    458

    Re: VBA code for formula....one more time

    Nope same error as before. There must be something wierd going on.

       Workbooks.Open Filename:=sPath2 & SFileInp2
        With ActiveSheet
            .Range("A1").Paste
            .Name = "105_12_31_2009_version1"

  2. #2
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: VBA code for formula....one more time

    I'm with you on that one. Can you upload a sample workbook. Have been in the pub for the last 4 days practically so I might be missing the obvious...
    "May the fleas of a thousand camels infest the crotch of the person who screws up your day and may their arms be too short to scratch..."

    Use code tags when posting your VBA code: [code] Your code here [/code]

    Remember, saying thanks only takes a second or two. Click the little star to give some Rep if you think an answer deserves it.

  3. #3
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: VBA code for formula....one more time

    There is no Paste method for a range; it's ActiveSheet.Paste or Range.PasteSpecial
       Workbooks.Open Filename:=sPath2 & SFileInp2
        With ActiveSheet
            .Range("A1").PasteSpecial
    Entia non sunt multiplicanda sine necessitate

  4. #4
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: VBA code for formula....one more time

    Doh! Think I might log off for the rest of the day to save further embarrassment...

    Dom

  5. #5
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Washington DC
    MS-Off Ver
    Excel 2007
    Posts
    458

    Re: VBA code for formula

    The following snippet works also:

        Workbooks.Open Filename:=sPath2 & SFileInp2
        With ActiveSheet
            .Paste Destination:=Range("A1")
    Anyother suggestions for tightning up the code?

  6. #6
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: VBA code for formula

    One tip would be instead of using Copy...PasteSpecialValues you can just write directly like this:

    Sheets ("Sheet1"), Range("A1:AV50000").Value = Sheets("Sheet2").Range("A1:AV50000").Value

    I would also maybe define your workbooks as objects, makes it easier to deal with when you are working with multiple workbooks.

    Dom.

+ 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