Find Next Empty Row In Excel And Populate With Data 追蹤
I've been learning VB as I go along for this application but the scenario is this:
I currently have the script running at the time a user prints a label (onIdentidcalCopies), it opens up a spreadsheet, updates information, saves then closes the spreadhseet with the code below:
Set objExcel = CreateObject("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Open("\\dt01.local\files$\UserFolders\samc\My Documents\Booker Card http://www.vbforums.com/showthread.php?735975-Find-Next-Empty-Row-in-Excel-and-Populate#\Printed Docs.xlsx")
objExcel.Application.Visible = True
objWorkbook.WorkSheets(1).Activate
objWorkbook.WorkSheets(1).Cells(1, 1).Value = "Test value2"
objExcel.ActiveWorkbook.Save
objExcel.ActiveWorkbook.Close
objExcel.Application.Quit
I could only find the code which would update a specified cell with the information given (1,1 for example). What I really need is for the code to move to the subsequent blank row below each time a label is printed to avoid overwriting information but I am stumped as to how to write this.
At this stage only one item is needed to be written to the spreadsheet so it will be restricted to column A, this will be variable data instead of fixed text as the script shows but I am fairly certain that's an http://www.vbforums.com/showthread.php?735975-Find-Next-Empty-Row-in-Excel-and-Populate# change I can make, I'd like to get the data sequencing right first.
Any help would be appreciated
3 意見
Hello Sam,
Thank you very much for your post. In order to don't overwrite your records in Excel we have some VBscript events as OnNewRecord() or OnPostPrompt() where you will be able to edit your VBscript
Carlos thanks for your reply. Our customer unfortunately wants to operate in a different mannor. They have issued us with a CSV file in MSDOS format containing the information to be printed on the label, hence is not a spreadsheet as such. We are then to update a seperate (new) spreadsheet with certain fields taken from Bartender which have been printed on the label. A method of tracking which records have been printed.
The part where my knowledge fell down was to prompt excel to look at column A and input the data in the next available empty row with the VB script in Bartender.
Hello Sam,
Thank you very much for your feedback.
Can you let me know why exactly do you need to write in your database?
The problem here is that in VBscript when you access to a database you will work in a record, in this record you will be able to write on every database fields but you will not be able to write on a different record.
Maybe with a very tedious workaround could be possible to write on a new record, however another problem is that if your code is writing in the next record on blank and your database connection is crossing the database until find empty records you will entry in a loop.
Please let us know what your customer is requesting exactly and we will check if there is an easier alternative.
請登入寫評論。