ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VBA copy and paste data (https://www.excelbanter.com/excel-programming/450186-vba-copy-paste-data.html)

Paul Mullan

VBA copy and paste data
 
Hi -

I have a spreadsheet that I am using as a database and a userform that I am using as the entry portal for the data being entered

I am trying to add some VBA to the userform that will copy data in columns A-C, but only from the last row of entered data. The VBA will run when button CommandButton1 is pressed.

Any help gratefully received

Paul


GS[_2_]

VBA copy and paste data
 
On 07/02/2014 9:29 AM, Paul Mullan wrote:
Hi -

I have a spreadsheet that I am using as a database and a userform that I am using as the entry portal for the data being entered

I am trying to add some VBA to the userform that will copy data in columns A-C, but only from the last row of entered data. The VBA will run when button CommandButton1 is pressed.

Any help gratefully received

Paul

Spreadsheets being used as a database need to be properly structured as
datatables! Userforms being used as dataforms need to be properly
configured to work as a dataform! If you expect reliable performance and
integretyy from your project then 'willy-nilly', unfortunately, just
won't 'cut it'!

Can you post a download link to your project file so we can better
advise you and/or provide a solution? (Please make sure the file
contains some sample data, and a fully explained expectation of how you
want your dataform to work!)

--
-
Garry

Free Usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion

Auric__

VBA copy and paste data
 
Paul Mullan wrote:

I have a spreadsheet that I am using as a database and a userform that I
am using as the entry portal for the data being entered

I am trying to add some VBA to the userform that will copy data in
columns A-C, but only from the last row of entered data. The VBA will
run when button CommandButton1 is pressed.


This copies (to the clipboard) from the bottom row that has any data in any
of those 3 columns:

workRow = 0
lastRow = Cells.SpecialCells(xlCellTypeLastCell).Row
For L0 = 1 To 3
If Len(Cells(lastRow, L0).Value) < 1 Then
r1 = Cells(lastRow, L0).End(xlUp).Row
Else
r1 = lastRow
End If
If workRow < r1 Then workRow = r1
Next
Range("A" & workRow & ":C" & workRow).Copy

--
- They're brainwashing you, watch out.
- but i'm hungry
- That's what they want you to think.

GS[_2_]

VBA copy and paste data
 
I forgot to mention that Excel has a builtin dataform for exactly the
purpose of your userform! Did you try using that instead?

--
-
Garry

Free Usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion


All times are GMT +1. The time now is 08:55 PM.

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