ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Pasting (https://www.excelbanter.com/excel-programming/442613-pasting.html)

Jim Berglund[_2_]

Pasting
 
I get a 1004 error code that states that the PasteSpecial Method of Range
Class Failed with the following

Columns("C:C").Select
Application.CutCopyMode = False
Selection.Copy
Range("E1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False

Is there a way to fix this?

Jim


Gary Keramidas[_4_]

Pasting
 
here are 3 differsnt ways, pick the one you want to use.

Sub test()
Dim ws As Worksheet
Set ws = Worksheets("Sheet1")
ws.Columns("E").Value = ws.Columns("C").Value
End Sub


Sub test1()
Dim ws As Worksheet
Set ws = Worksheets("Sheet1")
ws.Columns("C:C").Copy
ws.Range("E1").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
End Sub


Sub test2()
Dim lastrow As Long
Dim ws As Worksheet
Set ws = Worksheets("Sheet1")
lastrow = ws.Cells(Rows.Count, "C").End(xlUp).Row
ws.Range("E1:E" & lastrow).Value = ws.Range("C1:C" & lastrow).Value
End Sub


--


Gary Keramidas
Excel 2003


"Jim Berglund" wrote in message
...
I get a 1004 error code that states that the PasteSpecial Method of Range
Class Failed with the following

Columns("C:C").Select
Application.CutCopyMode = False
Selection.Copy
Range("E1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False

Is there a way to fix this?

Jim



Jim Berglund[_2_]

Pasting
 
Gary, I received your recoded application and was delighted with it. It
taught me a couple of new ways to think about the problem, and offered a
variety of new approaches that I'd have never considered (previously)

Thanks so much for your terrific support!
Jim

"Gary Keramidas" wrote in message
...
here are 3 differsnt ways, pick the one you want to use.

Sub test()
Dim ws As Worksheet
Set ws = Worksheets("Sheet1")
ws.Columns("E").Value = ws.Columns("C").Value
End Sub


Sub test1()
Dim ws As Worksheet
Set ws = Worksheets("Sheet1")
ws.Columns("C:C").Copy
ws.Range("E1").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
End Sub


Sub test2()
Dim lastrow As Long
Dim ws As Worksheet
Set ws = Worksheets("Sheet1")
lastrow = ws.Cells(Rows.Count, "C").End(xlUp).Row
ws.Range("E1:E" & lastrow).Value = ws.Range("C1:C" & lastrow).Value
End Sub


--


Gary Keramidas
Excel 2003


"Jim Berglund" wrote in message
...
I get a 1004 error code that states that the PasteSpecial Method of Range
Class Failed with the following

Columns("C:C").Select
Application.CutCopyMode = False
Selection.Copy
Range("E1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False

Is there a way to fix this?

Jim




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

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