help with code

N

Nicole Seibert

Hi,
I thought that this would work:

'*** NOTICE: This does not include the header row as we are adding on to the
bottom of
'what is already on BA Approved
Dim lastcell1 As Integer
lastcell1 = Range("A1").End(xlDown).Count
Range("A3:R(lastcell1)").Select
Range("R(lastcell1)").Activate
Selection.Copy
Sheets("Estimated - BA Approved").Select
'
'Find the first cell in column A WITHOUT Data and start paste in this cell
Range("A1").End(xlDown).Offset(1, 0).Select
ActiveSheet.Paste

It doesn't. First, can you tell me why? And two, is there simplier code
for selecting only rows with data, but not the two row header row?

Thanks,
Nicole
 
D

Dave Peterson

Dim lastRow As long 'not integer
dim DestCell as range

with worksheets("estimated - BA approved")
set destcell = .cells(.rows.count,"A").end(xlup).offset(1,0)
end with

with worksheets("sheet99") '<-- change this
lastrow = .cells(.rows.count,"A").end(xlup).row

.range("a3:R" & lastrow).copy _
destination:=destcell
end with


====
I changed "As Integer" to "As Long". If the number of rows is small, then it
won't matter. But if the number of rows grows to big, it might--and "As Long"
always works.

I also changed LastCell1 to LastRow (too many ell's and ones, <vbg>.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top