ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Coping values to the next empty row (https://www.excelbanter.com/excel-programming/274690-coping-values-next-empty-row.html)

Richard James[_2_]

Coping values to the next empty row
 
I need code that will paste two separate values in one
worksheet in the next available row. One value in
column "A" and the other value in column "B". The code
would paste the values as the user shuts down the program
in the same row of a specified worksheet. I need this to
collect a series of values from separate users who use
this program at different times of the day.

Thanks in advance,
Rich

Wild Bill[_2_]

Coping values to the next empty row
 
I assume that you have no problems coping but wish this:

The following pair would add values to the row beneath the bottom of the
sheet. If you want to put it somewhere higher, that will depend on the
design of your application, likely involving xlDown or such.

dim lLastRow as long
lLastRow = ActiveCell.SpecialCells(xlLastCell).Row
Range("A1").Offset(lLastRow, 0)="1st"
Range("A1").Offset(lLastRow, 1)="2nd"

Some considerations, best investigated by typing Control-End on your
sheet:
when sheet already extends to row 65536
when sheet has had rows deleted, so that the bottom of the sheet is
artificially "low"
when sheet has cells with formats but no values, so that the bottom is
artificially "low"


All times are GMT +1. The time now is 08:30 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com