Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to copy and paste an entire row? 1

Status
Not open for further replies.

RonQA

Technical User
Jun 24, 2007
61
US
I just cannot get this to work. I have tried so many different ways. Here is my latest attempt.

I want to copy - "Range("A11").EntireRow" to the last empty row on the same sheet. "objWorksheet.Range("F65536").End(xlUp).Row"


Range("A11").EntireRow.Copy r.Row

Code ==================================

Function UpdateExcel(ExcelFile)
'Update Excel Spredsheat ("F" Controls position of last Row. F = "Work Performed")
Const xlUp = &HFFFFEFBE
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = False
Set objWorkbook = objExcel.Workbooks.Open(ExcelFile)
Set objWorksheet = objWorkbook.Worksheets(1)
objWorksheet.Activate

r = objWorksheet.Range("F65536").End(xlUp).Row
If r = 1 And objWorksheet.Range("F" & r).value = "" Then
intNewRow = r
Else

intNewRow = r + 1


End If

'Update Cells
Range("A11").EntireRow.Copy r.Row
 


want to copy - "Range("A11").EntireRow" to the last empty row on the same sheet. "objWorksheet.Range("F65536").End(xlUp).Row"
Code:
Range("A11").EntireRow.Copy objWorksheet.cells(objWorksheet.rows.count, "A").End(xlUp).offset(1)


Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
I tried the code and it copied it to the first row instead of the last empty row.

I did a copy/paste with your code so I know it isn't a typo.

Am I missing something else?

Thanks
 



I notice that you had ("F65536")

Does column F have a different last row than column A?

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
I thought I knew where you were going with that question. It still did not work.

"F" is the column that I use to make sure that is the absolute last row with data. If data is there that I want the row after it.

Range("F11").EntireRow.Copy objWorksheet.Cells(objWorksheet.Rows.Count, "F").End(xlUp).Offset(1)

Thanks
 


That will not work because it needs to paste the entire row, in column A, not in any other column
Code:
Range("F11").EntireRow.Copy objWorksheet.Cells(objWorksheet.Rows.Count, "F").End(xlUp).Offset(1)[b].end(xltoleft)[/b]

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Thanks...appreciate the help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top