Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 153
Default Cut from one sheet, paste in another

Greetings folks. I need to cut the active row from one sheet, and paste it
into the first blank row in another sheet. So far this is what I have, and I
am not sure how to do it. I can activate the target row, but I am unable to
paste into it. Any ideas? Thank you.

Dim WS As Worksheet
Dim LastRow As Integer

'Cut the active row from the present sheet
ActiveCell.EntireRow.Cut

'Set the target sheet
Set WS = ActiveWorkbook.Sheets!held

'Set start row of the destination sheet
LastRow = 8

With WS
'Get the first blank row on destination sheet
For i = 8 To 300 Step 1
If Len(.Cells(i, 4).Value & "") 0 Then
LastRow = LastRow + 1
End If
Next i
'Need to paste the row that was cut from the previous sheet
'This is where I am getting errors.
.Cells(LastRow, 1).Paste
End With
'WS.Activate

Greg
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default Cut from one sheet, paste in another

Hi Greg,

For some reason when using Cut, Paste does not work unless you select the
worksheet then the cell and use ActiveSheet.Paste. Try the following.

..Cells(LastRow, 1).EntireRow.Insert Shift:=xlDown

Also the method you use to find the LastRow. Is it because you are looking
for the first available row and there is other data below it or is it the row
below all other data? If the former then leave as is but if the latter, the
following finds the next blank row on a worksheet.

With WS
LastRow = .Cells(.Rows.Count, 4).End(xlUp).Offset(1, 0).Row

--
Regards,

OssieMac


"Greg Snidow" wrote:

Greetings folks. I need to cut the active row from one sheet, and paste it
into the first blank row in another sheet. So far this is what I have, and I
am not sure how to do it. I can activate the target row, but I am unable to
paste into it. Any ideas? Thank you.

Dim WS As Worksheet
Dim LastRow As Integer

'Cut the active row from the present sheet
ActiveCell.EntireRow.Cut

'Set the target sheet
Set WS = ActiveWorkbook.Sheets!held

'Set start row of the destination sheet
LastRow = 8

With WS
'Get the first blank row on destination sheet
For i = 8 To 300 Step 1
If Len(.Cells(i, 4).Value & "") 0 Then
LastRow = LastRow + 1
End If
Next i
'Need to paste the row that was cut from the previous sheet
'This is where I am getting errors.
.Cells(LastRow, 1).Paste
End With
'WS.Activate

Greg

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 153
Default Cut from one sheet, paste in another

That's a good tip about the paste not working with cut unless the destination
is not selected. The user has some validation lists in the columns starting
at row 300, so I need to find the first blank row after row 8, but before row
300, thus the method of finding the blank row.

"OssieMac" wrote:

Hi Greg,

For some reason when using Cut, Paste does not work unless you select the
worksheet then the cell and use ActiveSheet.Paste. Try the following.

.Cells(LastRow, 1).EntireRow.Insert Shift:=xlDown

Also the method you use to find the LastRow. Is it because you are looking
for the first available row and there is other data below it or is it the row
below all other data? If the former then leave as is but if the latter, the
following finds the next blank row on a worksheet.

With WS
LastRow = .Cells(.Rows.Count, 4).End(xlUp).Offset(1, 0).Row

--
Regards,

OssieMac


"Greg Snidow" wrote:

Greetings folks. I need to cut the active row from one sheet, and paste it
into the first blank row in another sheet. So far this is what I have, and I
am not sure how to do it. I can activate the target row, but I am unable to
paste into it. Any ideas? Thank you.

Dim WS As Worksheet
Dim LastRow As Integer

'Cut the active row from the present sheet
ActiveCell.EntireRow.Cut

'Set the target sheet
Set WS = ActiveWorkbook.Sheets!held

'Set start row of the destination sheet
LastRow = 8

With WS
'Get the first blank row on destination sheet
For i = 8 To 300 Step 1
If Len(.Cells(i, 4).Value & "") 0 Then
LastRow = LastRow + 1
End If
Next i
'Need to paste the row that was cut from the previous sheet
'This is where I am getting errors.
.Cells(LastRow, 1).Paste
End With
'WS.Activate

Greg

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default Cut from one sheet, paste in another

Hi again Greg,

Because you say that there is other data from row 300 then the method I gave
you will continually push that data down. Therefore you need to delete a row
each time you insert one.

Note you can still use a similar method to the one I posted for finding the
next blank row by replacing '.Rows.Count' with 300.

'Find next blank row
LastRow = .Cells(300, 4).End(xlUp).Offset(1, 0).Row

'Inserts data but pushes all other data down.
..Cells(LastRow, 1).EntireRow.Insert Shift:=xlDown

'Deletes the row below inserted data
..Cells(300, 4).End(xlUp).Offset(1, 0).EntireRow.Delete


--
Regards,

OssieMac


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
loop through the workbook and paste every sheet it into newly createdworkbook with same sheet name vicky Excel Programming 3 November 9th 09 06:12 PM
Line count in sheet determines paste range in another sheet [email protected] Excel Programming 1 October 4th 08 01:26 PM
Line count in 1 sheet to determine paste range in 2nd sheet. [email protected] Excel Programming 0 September 26th 08 07:43 PM
Copy Paste from Class Sheet to Filtered List on Combined Sheet [email protected] Excel Programming 6 September 16th 08 04:30 PM
Help to code Macro to Copy fron one sheet and paste in other sheet kay Excel Programming 3 July 25th 08 06:46 PM


All times are GMT +1. The time now is 09:23 PM.

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

About Us

"It's about Microsoft Excel"