Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default Need Help with code to "Paste into next available row"

I am trying to move the datavalues from row2(worksheet2,"a2:ab2") to
worksheet3 next available blank row then clear the contents from cells
(c2:c10) in worksheet1. This line of code works fine for everything but
pasting to the next available blank row in worksheet3. It pastes the data
into row19 everytime overwriting previously input data. Worksheet3 has column
headings in row1 and blank rows from a2:A64000, except for row19 obviously.
Everything in the code works correctly except for lines 5 & 6. The line
numbers are not part of the code. I added them to simply communications.

1 Sheets("Formulas").Select
2 ActiveSheet.Range("a2:ab2").Select
3 Selection.Copy
4 Sheets("OperationalRates").Select
5 LastRow = Cells(Rows.Count, "a").End(xlUp).Row + 1
6 ActiveSheet.Rows(LastRow & ":" & LastRow).Select
7 Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks:=False, Transpose:=False

8 Sheets("InputForm").Range("c2:c10").ClearContents

End Sub
--
dhunter43
The Performance Advantage, LLC
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 180
Default Need Help with code to "Paste into next available row"

code line 5 & 6 should be resp
LastRow = Range("A65500").End(xlUp).Row + 1
Range("A"&LastRow).Select

Hope this helps!!
--
Pranav Vaidya
VBA Developer
PN, MH-India


"dhunter43" wrote:

I am trying to move the datavalues from row2(worksheet2,"a2:ab2") to
worksheet3 next available blank row then clear the contents from cells
(c2:c10) in worksheet1. This line of code works fine for everything but
pasting to the next available blank row in worksheet3. It pastes the data
into row19 everytime overwriting previously input data. Worksheet3 has column
headings in row1 and blank rows from a2:A64000, except for row19 obviously.
Everything in the code works correctly except for lines 5 & 6. The line
numbers are not part of the code. I added them to simply communications.

1 Sheets("Formulas").Select
2 ActiveSheet.Range("a2:ab2").Select
3 Selection.Copy
4 Sheets("OperationalRates").Select
5 LastRow = Cells(Rows.Count, "a").End(xlUp).Row + 1
6 ActiveSheet.Rows(LastRow & ":" & LastRow).Select
7 Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks:=False, Transpose:=False

8 Sheets("InputForm").Range("c2:c10").ClearContents

End Sub
--
dhunter43
The Performance Advantage, LLC

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default Need Help with code to "Paste into next available row"

I get this error message
Run time error '1004'
Select method of Range class failed

with this line hilighted in the VBA editor.
Range("A"&LastRow).Select

--
dhunter43
The Performance Advantage, LLC


"Pranav Vaidya" wrote:

code line 5 & 6 should be resp
LastRow = Range("A65500").End(xlUp).Row + 1
Range("A"&LastRow).Select

Hope this helps!!
--
Pranav Vaidya
VBA Developer
PN, MH-India


"dhunter43" wrote:

I am trying to move the datavalues from row2(worksheet2,"a2:ab2") to
worksheet3 next available blank row then clear the contents from cells
(c2:c10) in worksheet1. This line of code works fine for everything but
pasting to the next available blank row in worksheet3. It pastes the data
into row19 everytime overwriting previously input data. Worksheet3 has column
headings in row1 and blank rows from a2:A64000, except for row19 obviously.
Everything in the code works correctly except for lines 5 & 6. The line
numbers are not part of the code. I added them to simply communications.

1 Sheets("Formulas").Select
2 ActiveSheet.Range("a2:ab2").Select
3 Selection.Copy
4 Sheets("OperationalRates").Select
5 LastRow = Cells(Rows.Count, "a").End(xlUp).Row + 1
6 ActiveSheet.Rows(LastRow & ":" & LastRow).Select
7 Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks:=False, Transpose:=False

8 Sheets("InputForm").Range("c2:c10").ClearContents

End Sub
--
dhunter43
The Performance Advantage, LLC

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Need Help with code to "Paste into next available row"

try this from anywhere in the workbook. I don't understand how line 8
pertains
Sub PasteValues()
Set ss = Sheets("formulas")
Set ds = Sheets("operationalrates")
ss.Range("a2:d2").Copy
ds.Range("a" & ds.Cells(Rows.Count, "a").End(xlUp).Row + 1) _
.PasteSpecial Paste:=xlPasteValues
'???
Sheets("InputForm").Range("c2:c10").ClearContents
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"dhunter43" wrote in message
...
I am trying to move the datavalues from row2(worksheet2,"a2:ab2") to
worksheet3 next available blank row then clear the contents from cells
(c2:c10) in worksheet1. This line of code works fine for everything but
pasting to the next available blank row in worksheet3. It pastes the data
into row19 everytime overwriting previously input data. Worksheet3 has
column
headings in row1 and blank rows from a2:A64000, except for row19
obviously.
Everything in the code works correctly except for lines 5 & 6. The line
numbers are not part of the code. I added them to simply communications.

1 Sheets("Formulas").Select
2 ActiveSheet.Range("a2:ab2").Select
3 Selection.Copy
4 Sheets("OperationalRates").Select
5 LastRow = Cells(Rows.Count, "a").End(xlUp).Row + 1
6 ActiveSheet.Rows(LastRow & ":" & LastRow).Select
7 Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks:=False, Transpose:=False

8 Sheets("InputForm").Range("c2:c10").ClearContents

End Sub
--
dhunter43
The Performance Advantage, LLC


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
Paste in "match destination format" macro code Hopelesslylost Excel Discussion (Misc queries) 2 June 18th 06 01:58 PM
What is Error "Method "Paste" of object "_Worksheet" failed? vat Excel Programming 7 February 17th 06 08:05 PM
Complex if test program possible? If "value" "value", paste "value" in another cell? jseabold Excel Discussion (Misc queries) 1 January 30th 06 10:01 PM
Modify code to disable "paste" Jonsson[_34_] Excel Programming 0 June 17th 04 09:10 AM


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