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

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

Posted on 2004-09-14
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
  • 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 250 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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

860 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