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

Greeings. I apologize if this is a double post, but my first attempt does
not seem to have shown up. I need to cut the active row from the active
sheet, and paste it into the first blank row on another sheet. So far, this
is what I have. I could do it by selecting the target sheet and row, but I
would like to avoid moving from the active sheet if possible. Thank you.

Sub Test()

Dim WS As Worksheet
Dim LastRow As Integer

'Cut the active row from the active 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
.Range("A" & LastRow).Paste
End With

End Sub


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

Option Explicit
Sub Test()

Dim ToWks As Worksheet
Dim NextRow As Long

'Set the target sheet
Set ToWks = ActiveWorkbook.Worksheets("held")

With ToWks
NextRow = .Cells(.Rows.Count, "D").End(xlUp).Row + 1
If NextRow < 8 Then
NextRow = 8
End If
'Cut the active row from the active sheet
ActiveCell.EntireRow.Cut _
Destination:=.Cells(NextRow, "A")
End With

End Sub

Greg Snidow wrote:

Greeings. I apologize if this is a double post, but my first attempt does
not seem to have shown up. I need to cut the active row from the active
sheet, and paste it into the first blank row on another sheet. So far, this
is what I have. I could do it by selecting the target sheet and row, but I
would like to avoid moving from the active sheet if possible. Thank you.

Sub Test()

Dim WS As Worksheet
Dim LastRow As Integer

'Cut the active row from the active 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
.Range("A" & LastRow).Paste
End With

End Sub


--

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

Thanks Dave. I actually got it to work right after my post finally showed up
with this line, but your answere does exactly what I needed.

ActiveCell.EntireRow.Copy Destination:=Ws.Rows(LastRow)

"Dave Peterson" wrote:

Option Explicit
Sub Test()

Dim ToWks As Worksheet
Dim NextRow As Long

'Set the target sheet
Set ToWks = ActiveWorkbook.Worksheets("held")

With ToWks
NextRow = .Cells(.Rows.Count, "D").End(xlUp).Row + 1
If NextRow < 8 Then
NextRow = 8
End If
'Cut the active row from the active sheet
ActiveCell.EntireRow.Cut _
Destination:=.Cells(NextRow, "A")
End With

End Sub

Greg Snidow wrote:

Greeings. I apologize if this is a double post, but my first attempt does
not seem to have shown up. I need to cut the active row from the active
sheet, and paste it into the first blank row on another sheet. So far, this
is what I have. I could do it by selecting the target sheet and row, but I
would like to avoid moving from the active sheet if possible. Thank you.

Sub Test()

Dim WS As Worksheet
Dim LastRow As Integer

'Cut the active row from the active 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
.Range("A" & LastRow).Paste
End With

End Sub


--

Dave Peterson
.

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 02:05 PM.

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"