Automating Excel: find next available row & populate...

Posted on 2004-09-14
Medium Priority
Last Modified: 2010-05-02
hi... I half figured out how to do this, but came into a bit of a snag.

- What I want to do from VB6 is go to a specific worksheet in an Excel workbook.  (i.e. Sheet1)

- Check for the next available row in COLUMN B. (not A).  Meaning, the next row without any information written on it.

- Populate column B, C, E, and F with variables I'll capture within my VB6 application.

- Save / Close the the workbook.

Question by:NO_CARRIER
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2

Expert Comment

ID: 12055882
How far have you been able to get? Can you open the Excel workbook?

When you say next available row in column B, do you mean the next completely empty row, or the next row with no data in B, which may have data in other rows?

Author Comment

ID: 12055942
yeah I got the workbook open.

I'm using with xl.ActiveWorkbook.Sheets("Sheet1") to select Sheet1.

Next row with no data in column B which may have data in other rows is fine.  Whichever is easier to be honest.

Accepted Solution

Clippit earned 1000 total points
ID: 12056071
Here's code I built in VBA, but I think it's the same as what you'll need:

Dim objXLApp As New Excel.Application
Dim lngRow As Long

objXLApp.Workbooks.Open ("C:\temp\quickdata.xls") ' change to your filename

With objXLApp.ActiveWorkbook
  With .Worksheets("Sheet1")
    lngRow = .Range("B65535").End(xlUp).Row + 1 ' find the row to use based on column B data
    .Cells(lngRow, 2) = "New Data" ' put the rest of the cell updates here
  End With
End With

Set objXLApp = Nothing

Author Comment

ID: 12064390
thanks... worked without any problems at all!

Expert Comment

ID: 12069514
You're welcome!

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question