Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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/

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default 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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default 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/

.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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/



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Insert copied cells Martin B Excel Worksheet Functions 3 August 30th 06 10:47 PM
Insert Copied Cells? HockeyFan Excel Discussion (Misc queries) 2 February 17th 06 01:32 PM
Excel - Insert Copied Cells jmrd Excel Discussion (Misc queries) 0 February 14th 06 09:52 PM
insert copied cells maryj Excel Discussion (Misc queries) 1 October 24th 05 07:56 PM
Copy row, Insert>Copied>Cells crashes Excel Kent Excel Discussion (Misc queries) 0 April 26th 05 10:48 PM


All times are GMT +1. The time now is 10:18 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"