Results 1 to 7 of 7

VBA find empty row in closed workbook

Threaded View

  1. #1
    Registered User
    Join Date
    03-12-2014
    Location
    Windsor, UK
    MS-Off Ver
    Excel 2007
    Posts
    43

    VBA find empty row in closed workbook

    Hi All

    Hoping someone can help me out with this. I've managed to find a nice bit of code that allows me to open a closed workbook in order to write data into it from a opened workbook. But I keep getting an Object Required error when i try to run the code.

    What I'm trying to do, is have the code go into the closed workbook, find the first empty row on the sheet, then write the data into it form the sheet 'mydata' which is in the opened workbook, (hope that makes sense?):

    Dim xl0 As New Excel.Application
        Dim xlw As New Excel.Workbook
        Set xlw = xl0.Workbooks.Open("I:\myfilepath\myfile.xlsm")
    
    
     
    emptyRow = WorksheetFunction.CountA(x10.Sheets("Data").Range("A:A")) + 1
    
    
    
    x10.Sheets("Data").Cells(emptyRow, 1).Value = Sheets("mydata").Range("A2").Value
    x10.Sheets("Data").Cells(emptyRow, 2).Value = Sheets("mydata").Range("B2").Value
     
    
    
     
        xlw.Save
        xlw.Close
    
    
        
        Set xl0 = Nothing

    Feel like i'm almost there, just can't figure out the error!

    any help would be greatly appreciated!

    Many thanks in advance for your help
    Last edited by Broobi; 09-08-2015 at 01:43 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Update Cell Value from a Closed Workbook to Another Closed Workbook
    By glennchung in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-17-2014, 04:44 PM
  2. Replies: 0
    Last Post: 03-27-2014, 12:38 PM
  3. Replies: 0
    Last Post: 08-25-2013, 11:28 PM
  4. Copy range from closed excel workbook into master file + finding next empty row
    By ralphmeys in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-22-2013, 12:56 PM
  5. Find last row in closed workbook using file path name
    By amazingg64 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-27-2012, 09:22 AM
  6. Code to find value from closed workbook?
    By Yappa in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-23-2012, 01:27 PM
  7. Find data in a closed workbook
    By JonesZoid in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 01-29-2010, 03:49 AM

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