View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.programming
Don Guillett Don Guillett is offline
external usenet poster
 
Posts: 10,124
Default My macro won't find the last row !

A lot of this is my fault for being in a hurry when I tried to help clean up
your code. This idea here HAS been tested
I am finding the last row on sheet3 which is NOT the active sheet. As was
pointed out, notice the .'s in the with. I am copying range("a4:d" & LR) to
the active sheet. Either line works.

Sub dolastrowexercise()
With Sheets("sheet3")
LR = .Cells(Rows.Count, "H").End(xlUp).Row
MsgBox LR
'.Range(.Cells(4, 1), .Cells(LR, 4)).Copy Range("a15")
..Range("a4:d" & LR).Copy Range("a15")'with .'s
'.Range("a4:d" & LR).Copy sheets("sheet5").Range("a15")'no dots
End With
End Sub


--
Don Guillett
SalesAid Software

"Roger" wrote in message
...
This is the code that I am using. When I run it still get an error on the
line .LR = .Cells(Rows.Count, "H").End(xlUp).Row + 1. Any ideas ?? It just
does not want to count the rows to determine which row is the last row in
the table of data ! thanks ... Roger


With Worksheets("Report (zonderArb)")
.LR = .Cells(Rows.Count, "H").End(xlUp).Row + 1
.Range("H" & LR).Formula = "=sum(h1:h" & LR + 1 & ")"
.Range("H" & LR).Copy Range(.Cells(LR, "I"), .Cells(LR, "ae"))
.Range(.Cells(LR, "A"), .Cells(LR, "g")).Borders.LineStyle = xlContinuous
.Range(.Cells(LR, "h"), .Cells(LR, "o")).Borders.LineStyle = xlContinuous
.Range(.Cells(LR, "p"), .Cells(LR, "w")).Borders.LineStyle = xlContinuous
.Range(.Cells(LR, "x"), .Cells(LR, "ae")).Borders.LineStyle = xlContinuous
.Range("AF" & LR).Borders.LineStyle = xlContinuous

.Range(.Cells(l4, "M"), .Cells(LR, "n")).NumberFormat = "0.00"
.Range(.Cells(l4, "u"), .Cells(LR, "v")).NumberFormat = "0.00"
.Range(.Cells(l4, "ac"), .Cells(LR, "ad")).NumberFormat = "0.00"
.Range("G" & LR) = "Totals"

With Range("G" & LR).Characters(Start:=1, Length:=7).Font
.Name = "Arial"
.FontStyle = "Regular"
.Size = 8
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = 1
End With

End With

'Sheets("Instructions").Select
' Range("K61").Select
ActiveWorkbook.Save
End Sub