ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Excel 2002 - VBA code to insert copied cells?? (https://www.excelbanter.com/excel-programming/286196-excel-2002-vba-code-insert-copied-cells.html)

rglasunow

Excel 2002 - VBA code to insert copied cells??
 
I would like to write a macro to copy a selected amount of data and
paste it onto the next avaliable row. However the worksheet is
continually expanding and it will not always go in the same row. Is
there a way to write the marco to paste the copied data?

I already know how to write the macro to copy all the cells but I just
need to know how to tell it to paste into the growing spreadsheet.

Thank you,
Ryan


---
Message posted from http://www.ExcelForum.com/


Jim Rech

Excel 2002 - VBA code to insert copied cells??
 
and paste it onto the next avaliable row.

It would help people to help you if you explained what you mean here. An
example perhaps.

--
Jim Rech
Excel MVP



Brad Vontur

Excel 2002 - VBA code to insert copied cells??
 
If I understood you, this should work. Make sure you have
something in the clipboard or it will error out. Not sure
how to check for that without using api.

Private Sub CommandButton1_Click()
' Grab the current worksheet.
Dim shtCurrent As Worksheet
Set shtCurrent = ActiveSheet
' Identify the last used row.
Dim rngLastRow As Range
Set rngLastRow = shtCurrent.UsedRange.Rows
(shtCurrent.UsedRange.Rows.Count)
' Find the first cell in the last used row.
Dim rngLastCell As Range
Set rngLastCell = rngLastRow.Cells(1, 1)
' Increment down one row to identify the target paste
cell.
Dim rngPasteTarget As Range
Set rngPasteTarget = rngLastCell.Offset(1, 0)
' Paste it.
rngPasteTarget.PasteSpecial
End Sub

HTH.
-----Original Message-----
I would like to write a macro to copy a selected amount

of data and
paste it onto the next avaliable row. However the

worksheet is
continually expanding and it will not always go in the

same row. Is
there a way to write the marco to paste the copied data?

I already know how to write the macro to copy all the

cells but I just
need to know how to tell it to paste into the growing

spreadsheet.

Thank you,
Ryan


---
Message posted from http://www.ExcelForum.com/

.


Tom Ogilvy

Excel 2002 - VBA code to insert copied cells??
 
If column A of the destination sheet will always have data in it

worksheets("DestSheetName").Cells(rows.count,1).En d(xlup)(2).Paste

--
Regards,
Tom Ogilvy

rglasunow wrote in message
...
I would like to write a macro to copy a selected amount of data and
paste it onto the next avaliable row. However the worksheet is
continually expanding and it will not always go in the same row. Is
there a way to write the marco to paste the copied data?

I already know how to write the macro to copy all the cells but I just
need to know how to tell it to paste into the growing spreadsheet.

Thank you,
Ryan


---
Message posted from http://www.ExcelForum.com/





All times are GMT +1. The time now is 05:35 PM.

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