Solved

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

Posted on 2004-09-14
5
253 Views
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.


0
Comment
Question by:NO_CARRIER
  • 3
  • 2
5 Comments
 
LVL 1

Expert Comment

by:Clippit
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?
0
 
LVL 1

Author Comment

by:NO_CARRIER
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.
0
 
LVL 1

Accepted Solution

by:
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
  .Save
  .Close
End With

Set objXLApp = Nothing
====================================
0
 
LVL 1

Author Comment

by:NO_CARRIER
ID: 12064390
thanks... worked without any problems at all!
0
 
LVL 1

Expert Comment

by:Clippit
ID: 12069514
You're welcome!
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…

708 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now