Closed Thread
Page 2 of 3 FirstFirst 1 2 3 LastLast
Results 11 to 20 of 23

Thread: Excel (take worksheet from 2 files?)

  1. #11
    Super Sarcasm Mistress mehere is a glorious beacon of light mehere is a glorious beacon of light mehere is a glorious beacon of light mehere is a glorious beacon of light mehere is a glorious beacon of light mehere's Avatar
    Join Date
    Mar 2008
    Location
    Wide Awake In Dreamland
    Posts
    830
    Rep Power
    8

    to step through a macro, you would go into Tools >> Macro >> Visual Basic Editor. if Macro1 isn't showing then on the left hand side, double click Module 1 to pull up the macro.

    in the gray area, click you mouse next to this line: Workbooks.Open Filename:=varFile1, this will put a dot in the gray area and highlight the line. then click Debug >> Step Into. then to go to each line, click F8 and watch what it's doing. let me know exactly which line is erroring.
    Quote of the Month:
    INSIGHT: When the going gets tough, the tough get going. The smart left a long time ago.

    Questions to Ponder:
    Are people more violently opposed to fur rather than leather because it's much easier to harass rich women than motorcycle gangs?

    iif([sarcasm]=true,iif([you have to ask]=true,"didn't work","ha ha ha"),"not sarcasm")
    copyright © 2008 sbenj69

    Sarchasm: The gulf between the author of sarcastic wit and the person who doesn't get it.

  2. #12
    Barn Legend Rebelle will become famous soon enough Rebelle's Avatar
    Join Date
    Mar 2008
    Posts
    1,522
    Rep Power
    5

    w00t...I stepped thru. i could see it opened file1 and highlighted header column and rows A-D like I want and then it did a copy but after error.

    Still giving the error on line below in bold:

    Code:
    'Full File Names
        varFile1 = strLocation & "\" & strFile1
        varFile2 = strLocation & "\" & strFile2
        
        'Open strFile1 for copying
        Workbooks.Open Filename:=varFile1
        If WorksheetFunction.CountA(Cells) > 0 Then
            'Search for any entry, by searching backwards by Rows.
            LastRow = Cells.Find(What:="*", After:=[A1], _
                  SearchOrder:=xlByRows, _
                  SearchDirection:=xlPrevious).Row
                  'MsgBox LastRow
        End If
        strRange1 = "A1:D" & LastRow
        Range(strRange1).Select
        Selection.Copy
        Windows("Final_Template").Activate 

  3. #13
    Super Sarcasm Mistress mehere is a glorious beacon of light mehere is a glorious beacon of light mehere is a glorious beacon of light mehere is a glorious beacon of light mehere is a glorious beacon of light mehere's Avatar
    Join Date
    Mar 2008
    Location
    Wide Awake In Dreamland
    Posts
    830
    Rep Power
    8

    make sure you only have 1 copy of final_template.xls open.
    Quote of the Month:
    INSIGHT: When the going gets tough, the tough get going. The smart left a long time ago.

    Questions to Ponder:
    Are people more violently opposed to fur rather than leather because it's much easier to harass rich women than motorcycle gangs?

    iif([sarcasm]=true,iif([you have to ask]=true,"didn't work","ha ha ha"),"not sarcasm")
    copyright © 2008 sbenj69

    Sarchasm: The gulf between the author of sarcastic wit and the person who doesn't get it.

  4. #14
    Barn Legend Rebelle will become famous soon enough Rebelle's Avatar
    Join Date
    Mar 2008
    Posts
    1,522
    Rep Power
    5

    not sure why machine didn't like it without .xls but i added it for all final_template and works beautifully!!! You're awesome!

  5. #15
    Super Sarcasm Mistress mehere is a glorious beacon of light mehere is a glorious beacon of light mehere is a glorious beacon of light mehere is a glorious beacon of light mehere is a glorious beacon of light mehere's Avatar
    Join Date
    Mar 2008
    Location
    Wide Awake In Dreamland
    Posts
    830
    Rep Power
    8

    cool ... it could be the version of software that requires that. i was just gonna suggest doing that. test it with two real files and make sure it works the way you want it to.
    Quote of the Month:
    INSIGHT: When the going gets tough, the tough get going. The smart left a long time ago.

    Questions to Ponder:
    Are people more violently opposed to fur rather than leather because it's much easier to harass rich women than motorcycle gangs?

    iif([sarcasm]=true,iif([you have to ask]=true,"didn't work","ha ha ha"),"not sarcasm")
    copyright © 2008 sbenj69

    Sarchasm: The gulf between the author of sarcastic wit and the person who doesn't get it.

  6. #16
    Barn Legend Rebelle will become famous soon enough Rebelle's Avatar
    Join Date
    Mar 2008
    Posts
    1,522
    Rep Power
    5

    w00t..this is soooo good. i was able to follow the code you applied and got it to create a pivot table and pull in another file with info.

    but i have another question. if you take File2.xls in post dated Feb 13 from me, i start with adding 4 columns A-D and then in A2 - D2 enter formulas, but then I have to copy/paste all down to last row. Can this be done with code to automatically copy/paste down to last row?

    I've tried with another file in the past that uses vlookup for 5 columns but it would never copy down.

  7. #17
    Barn Newbie Mythily is an unknown quantity at this point Mythily's Avatar
    Join Date
    Apr 2009
    Posts
    4
    Rep Power
    3

    You can use drag and drop, instead of copying it till the end.

  8. #18
    Super Sarcasm Mistress mehere is a glorious beacon of light mehere is a glorious beacon of light mehere is a glorious beacon of light mehere is a glorious beacon of light mehere is a glorious beacon of light mehere's Avatar
    Join Date
    Mar 2008
    Location
    Wide Awake In Dreamland
    Posts
    830
    Rep Power
    8

    w00t..this is soooo good. i was able to follow the code you applied and got it to create a pivot table and pull in another file with info.

    but i have another question. if you take File2.xls in post dated Feb 13 from me, i start with adding 4 columns A-D and then in A2 - D2 enter formulas, but then I have to copy/paste all down to last row. Can this be done with code to automatically copy/paste down to last row?

    I've tried with another file in the past that uses vlookup for 5 columns but it would never copy down.
    i never saw this question ... yes it can be done in code. you just need to be able to get the last row and last column being used than you can just select that range and paste it. if you can show me what you need, i can write it up real quick.
    Quote of the Month:
    INSIGHT: When the going gets tough, the tough get going. The smart left a long time ago.

    Questions to Ponder:
    Are people more violently opposed to fur rather than leather because it's much easier to harass rich women than motorcycle gangs?

    iif([sarcasm]=true,iif([you have to ask]=true,"didn't work","ha ha ha"),"not sarcasm")
    copyright © 2008 sbenj69

    Sarchasm: The gulf between the author of sarcastic wit and the person who doesn't get it.

  9. #19
    Barn Legend Rebelle will become famous soon enough Rebelle's Avatar
    Join Date
    Mar 2008
    Posts
    1,522
    Rep Power
    5

    Hey Mehere,

    Ok, I've attached spreadsheet. I get the file with only second tab __Data...without the columns highlighted. I then add the first tab __Lookup and then I add highlighted columns on __Data tab. I create a vlookup on the __lookup data..you'll be able to see formulas.

    I'd like to be able to run a macro to input the formulas from B2:K2 and copy/paste all the way down. Every time I get this file, the number of rows will be different...

    Thanks so much for looking at this!
    Attached Files

  10. #20
    Super Sarcasm Mistress mehere is a glorious beacon of light mehere is a glorious beacon of light mehere is a glorious beacon of light mehere is a glorious beacon of light mehere is a glorious beacon of light mehere's Avatar
    Join Date
    Mar 2008
    Location
    Wide Awake In Dreamland
    Posts
    830
    Rep Power
    8

    will it always be column B through column K? if so, here's the VBA Code ...
    Code:
    Sub copyFormulas()
        lastRow = ActiveSheet.UsedRange.Rows.Count
        Range("B2:K2").Select
        Selection.Copy
        Range("B3:K" & lastRow).Select
        ActiveSheet.Paste
    End Sub
    
    Last edited by mehere; April 22nd, 2009 at 02:42 PM.
    Quote of the Month:
    INSIGHT: When the going gets tough, the tough get going. The smart left a long time ago.

    Questions to Ponder:
    Are people more violently opposed to fur rather than leather because it's much easier to harass rich women than motorcycle gangs?

    iif([sarcasm]=true,iif([you have to ask]=true,"didn't work","ha ha ha"),"not sarcasm")
    copyright © 2008 sbenj69

    Sarchasm: The gulf between the author of sarcastic wit and the person who doesn't get it.

Closed Thread
Page 2 of 3 FirstFirst 1 2 3 LastLast

Similar Threads

  1. Tip for Reports Exported to Excel
    By Lauramc in forum SQL Server Reporting Services Help
    Replies: 0
    Last Post: January 13th, 2009, 10:09 PM
  2. From excel to database/web app
    By Rebelle in forum Database Design Help
    Replies: 7
    Last Post: July 10th, 2008, 02:36 PM
  3. Dynamically Reference Worksheet Cell/Range
    By BLaaaaaaaaaarche in forum Microsoft Office
    Replies: 2
    Last Post: June 18th, 2008, 04:59 PM
  4. Excel question
    By Rebelle in forum Microsoft Office
    Replies: 11
    Last Post: May 27th, 2008, 08:22 PM
  5. Retrieving Web Data using Excel
    By mehere in forum Microsoft Office
    Replies: 13
    Last Post: May 22nd, 2008, 04:14 PM

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

SEO by vBSEO