Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 44
Default Copy and paste entire line starting at cell W

This is the current macro that I am using. This would work if it would paste
starting at W. I currently use it to populate A thru V from different
worksheets. I have changed the names of the worksheets but have yet to be
able to get it to paste starting at W. The specific line that has been
causing
me issues was line 9 I believe.

Line: oCell.EntireRow.Copy Destination:=Sheets("PTR").Range("W" &
Rows.Count).End(xlUp).Offset(1, 0)

This line should paste all of the reference data line into PTR starting at
W. Can you assist with this?

Sub Copy2()

Dim Rng As Range, Rng1 As Range, MyCell As Range, oCell As Range, i As Long
Set Rng = Sheets("Reference Data").Range("A1:A" & Sheets("Reference
Data").Range("A" & Rows.Count).End(xlUp).Row)
Set Rng1 = Sheets("PTR").Range("A1:A" & Sheets("PTR").Range("A" &
Rows.Count).End(xlUp).Row)
i = 0
For Each MyCell In Rng1
For Each oCell In Rng
If oCell.Value = MyCell.Value Then
oCell.EntireRow.Copy Destination:=Sheets("PTR").Range("A" &
Rows.Count).End(xlUp).Offset(1, 0)
i = i + 1
End If
Next oCell
Next MyCell
i = 0
' Referencedata Macro
'
' Keyboard Shortcut: Ctrl+b

End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Copy and paste entire line starting at cell W

You can't paste the entire row if you're pasting into column W--or any column
but A!

Dim RngToCopy As Range
Dim DestCell as range

'A:V is 22 columns
set rngtocopy = ocell.entirerow.resize(1,22)

with worksheets("PTR")
Set Destcell = .cells(.rows.count,"W").end(xlup).offset(1,0)
end with

rngtocopy.copy _
destination:=destcell

=====
I like to use variables for my ranges instead of doing all the work in the .copy
command.


Kcope8302 wrote:

This is the current macro that I am using. This would work if it would paste
starting at W. I currently use it to populate A thru V from different
worksheets. I have changed the names of the worksheets but have yet to be
able to get it to paste starting at W. The specific line that has been
causing
me issues was line 9 I believe.

Line: oCell.EntireRow.Copy Destination:=Sheets("PTR").Range("W" &
Rows.Count).End(xlUp).Offset(1, 0)

This line should paste all of the reference data line into PTR starting at
W. Can you assist with this?

Sub Copy2()

Dim Rng As Range, Rng1 As Range, MyCell As Range, oCell As Range, i As Long
Set Rng = Sheets("Reference Data").Range("A1:A" & Sheets("Reference
Data").Range("A" & Rows.Count).End(xlUp).Row)
Set Rng1 = Sheets("PTR").Range("A1:A" & Sheets("PTR").Range("A" &
Rows.Count).End(xlUp).Row)
i = 0
For Each MyCell In Rng1
For Each oCell In Rng
If oCell.Value = MyCell.Value Then
oCell.EntireRow.Copy Destination:=Sheets("PTR").Range("A" &
Rows.Count).End(xlUp).Offset(1, 0)
i = i + 1
End If
Next oCell
Next MyCell
i = 0
' Referencedata Macro
'
' Keyboard Shortcut: Ctrl+b

End Sub


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 44
Default Copy and paste entire line starting at cell W

Pasting the whole row seemed like the easiest option. I only need 4 cells (
L,M.N,O) from Reference Data worksheet to be copied into that specific row
after a match in the A Column is found and put into the matching row in
PTR(W,X,Y,Z).

"Dave Peterson" wrote:

You can't paste the entire row if you're pasting into column W--or any column
but A!

Dim RngToCopy As Range
Dim DestCell as range

'A:V is 22 columns
set rngtocopy = ocell.entirerow.resize(1,22)

with worksheets("PTR")
Set Destcell = .cells(.rows.count,"W").end(xlup).offset(1,0)
end with

rngtocopy.copy _
destination:=destcell

=====
I like to use variables for my ranges instead of doing all the work in the .copy
command.


Kcope8302 wrote:

This is the current macro that I am using. This would work if it would paste
starting at W. I currently use it to populate A thru V from different
worksheets. I have changed the names of the worksheets but have yet to be
able to get it to paste starting at W. The specific line that has been
causing
me issues was line 9 I believe.

Line: oCell.EntireRow.Copy Destination:=Sheets("PTR").Range("W" &
Rows.Count).End(xlUp).Offset(1, 0)

This line should paste all of the reference data line into PTR starting at
W. Can you assist with this?

Sub Copy2()

Dim Rng As Range, Rng1 As Range, MyCell As Range, oCell As Range, i As Long
Set Rng = Sheets("Reference Data").Range("A1:A" & Sheets("Reference
Data").Range("A" & Rows.Count).End(xlUp).Row)
Set Rng1 = Sheets("PTR").Range("A1:A" & Sheets("PTR").Range("A" &
Rows.Count).End(xlUp).Row)
i = 0
For Each MyCell In Rng1
For Each oCell In Rng
If oCell.Value = MyCell.Value Then
oCell.EntireRow.Copy Destination:=Sheets("PTR").Range("A" &
Rows.Count).End(xlUp).Offset(1, 0)
i = i + 1
End If
Next oCell
Next MyCell
i = 0
' Referencedata Macro
'
' Keyboard Shortcut: Ctrl+b

End Sub


--

Dave Peterson

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Copy and paste entire line starting at cell W

Try changing this:
set rngtocopy = ocell.entirerow.resize(1,22)
to:
set rngtocopy = ocell.entirerow.range("L1:O1")





Kcope8302 wrote:

Pasting the whole row seemed like the easiest option. I only need 4 cells (
L,M.N,O) from Reference Data worksheet to be copied into that specific row
after a match in the A Column is found and put into the matching row in
PTR(W,X,Y,Z).

"Dave Peterson" wrote:

You can't paste the entire row if you're pasting into column W--or any column
but A!

Dim RngToCopy As Range
Dim DestCell as range

'A:V is 22 columns
set rngtocopy = ocell.entirerow.resize(1,22)

with worksheets("PTR")
Set Destcell = .cells(.rows.count,"W").end(xlup).offset(1,0)
end with

rngtocopy.copy _
destination:=destcell

=====
I like to use variables for my ranges instead of doing all the work in the .copy
command.


Kcope8302 wrote:

This is the current macro that I am using. This would work if it would paste
starting at W. I currently use it to populate A thru V from different
worksheets. I have changed the names of the worksheets but have yet to be
able to get it to paste starting at W. The specific line that has been
causing
me issues was line 9 I believe.

Line: oCell.EntireRow.Copy Destination:=Sheets("PTR").Range("W" &
Rows.Count).End(xlUp).Offset(1, 0)

This line should paste all of the reference data line into PTR starting at
W. Can you assist with this?

Sub Copy2()

Dim Rng As Range, Rng1 As Range, MyCell As Range, oCell As Range, i As Long
Set Rng = Sheets("Reference Data").Range("A1:A" & Sheets("Reference
Data").Range("A" & Rows.Count).End(xlUp).Row)
Set Rng1 = Sheets("PTR").Range("A1:A" & Sheets("PTR").Range("A" &
Rows.Count).End(xlUp).Row)
i = 0
For Each MyCell In Rng1
For Each oCell In Rng
If oCell.Value = MyCell.Value Then
oCell.EntireRow.Copy Destination:=Sheets("PTR").Range("A" &
Rows.Count).End(xlUp).Offset(1, 0)
i = i + 1
End If
Next oCell
Next MyCell
i = 0
' Referencedata Macro
'
' Keyboard Shortcut: Ctrl+b

End Sub


--

Dave Peterson


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 44
Default Copy and paste entire line starting at cell W

Do I paste this right into a basic module and run it as a standard macro?

"Dave Peterson" wrote:

Try changing this:
set rngtocopy = ocell.entirerow.resize(1,22)
to:
set rngtocopy = ocell.entirerow.range("L1:O1")





Kcope8302 wrote:

Pasting the whole row seemed like the easiest option. I only need 4 cells (
L,M.N,O) from Reference Data worksheet to be copied into that specific row
after a match in the A Column is found and put into the matching row in
PTR(W,X,Y,Z).

"Dave Peterson" wrote:

You can't paste the entire row if you're pasting into column W--or any column
but A!

Dim RngToCopy As Range
Dim DestCell as range

'A:V is 22 columns
set rngtocopy = ocell.entirerow.resize(1,22)

with worksheets("PTR")
Set Destcell = .cells(.rows.count,"W").end(xlup).offset(1,0)
end with

rngtocopy.copy _
destination:=destcell

=====
I like to use variables for my ranges instead of doing all the work in the .copy
command.


Kcope8302 wrote:

This is the current macro that I am using. This would work if it would paste
starting at W. I currently use it to populate A thru V from different
worksheets. I have changed the names of the worksheets but have yet to be
able to get it to paste starting at W. The specific line that has been
causing
me issues was line 9 I believe.

Line: oCell.EntireRow.Copy Destination:=Sheets("PTR").Range("W" &
Rows.Count).End(xlUp).Offset(1, 0)

This line should paste all of the reference data line into PTR starting at
W. Can you assist with this?

Sub Copy2()

Dim Rng As Range, Rng1 As Range, MyCell As Range, oCell As Range, i As Long
Set Rng = Sheets("Reference Data").Range("A1:A" & Sheets("Reference
Data").Range("A" & Rows.Count).End(xlUp).Row)
Set Rng1 = Sheets("PTR").Range("A1:A" & Sheets("PTR").Range("A" &
Rows.Count).End(xlUp).Row)
i = 0
For Each MyCell In Rng1
For Each oCell In Rng
If oCell.Value = MyCell.Value Then
oCell.EntireRow.Copy Destination:=Sheets("PTR").Range("A" &
Rows.Count).End(xlUp).Offset(1, 0)
i = i + 1
End If
Next oCell
Next MyCell
i = 0
' Referencedata Macro
'
' Keyboard Shortcut: Ctrl+b

End Sub

--

Dave Peterson


--

Dave Peterson



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Copy and paste entire line starting at cell W

It would be incorporated into your existing code.

If you have trouble, share that existing code.

Kcope8302 wrote:

Do I paste this right into a basic module and run it as a standard macro?

"Dave Peterson" wrote:

Try changing this:
set rngtocopy = ocell.entirerow.resize(1,22)
to:
set rngtocopy = ocell.entirerow.range("L1:O1")





Kcope8302 wrote:

Pasting the whole row seemed like the easiest option. I only need 4 cells (
L,M.N,O) from Reference Data worksheet to be copied into that specific row
after a match in the A Column is found and put into the matching row in
PTR(W,X,Y,Z).

"Dave Peterson" wrote:

You can't paste the entire row if you're pasting into column W--or any column
but A!

Dim RngToCopy As Range
Dim DestCell as range

'A:V is 22 columns
set rngtocopy = ocell.entirerow.resize(1,22)

with worksheets("PTR")
Set Destcell = .cells(.rows.count,"W").end(xlup).offset(1,0)
end with

rngtocopy.copy _
destination:=destcell

=====
I like to use variables for my ranges instead of doing all the work in the .copy
command.


Kcope8302 wrote:

This is the current macro that I am using. This would work if it would paste
starting at W. I currently use it to populate A thru V from different
worksheets. I have changed the names of the worksheets but have yet to be
able to get it to paste starting at W. The specific line that has been
causing
me issues was line 9 I believe.

Line: oCell.EntireRow.Copy Destination:=Sheets("PTR").Range("W" &
Rows.Count).End(xlUp).Offset(1, 0)

This line should paste all of the reference data line into PTR starting at
W. Can you assist with this?

Sub Copy2()

Dim Rng As Range, Rng1 As Range, MyCell As Range, oCell As Range, i As Long
Set Rng = Sheets("Reference Data").Range("A1:A" & Sheets("Reference
Data").Range("A" & Rows.Count).End(xlUp).Row)
Set Rng1 = Sheets("PTR").Range("A1:A" & Sheets("PTR").Range("A" &
Rows.Count).End(xlUp).Row)
i = 0
For Each MyCell In Rng1
For Each oCell In Rng
If oCell.Value = MyCell.Value Then
oCell.EntireRow.Copy Destination:=Sheets("PTR").Range("A" &
Rows.Count).End(xlUp).Offset(1, 0)
i = i + 1
End If
Next oCell
Next MyCell
i = 0
' Referencedata Macro
'
' Keyboard Shortcut: Ctrl+b

End Sub

--

Dave Peterson


--

Dave Peterson


--

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
How I write "if cell value =1, copy entire row & paste at dest. Dick Kusleika[_4_] Excel Programming 0 May 28th 08 04:42 PM
recognize the text within a cell and copy/paste whole line to nex. justyna Excel Programming 1 April 1st 07 12:40 AM
want to copy entire text box and paste in new cell delbridk Excel Discussion (Misc queries) 4 October 2nd 06 05:33 PM
Copy entire columns starting from a certain cell down cheeser83 Excel Programming 2 August 1st 06 03:52 PM
How to indicate in formula to choose the entire column starting from a specified cell? [email protected] Excel Discussion (Misc queries) 3 June 13th 06 04:25 AM


All times are GMT +1. The time now is 12:21 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"