LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 103
Default with, end with

greetings, i'm using with and end with to copy a row, the with statement
specifying a worksheet. i need to do this operation over couple worksheets,
and when i run macro there's a bug. doesn't seem to do instructions in with
statement on sheets that aren't the active window. how can i correct this?
here's code:

Sub database()

Dim oldr As Integer
Dim newr As Integer
Dim width As Integer

oldr = Range("cCollar").Rows.count
newr = Range("grid").Rows.count
width = Range("grid").Columns.count

If newr < oldr Then
Worksheets("rating").Range(Cells(oldr + 3, 2), Cells(newr + 2, width +
1)).ClearContents
Worksheets("output").Range(Cells(oldr + 3, 3), Cells(newr + 2, width +
1)).ClearContents
End If

If oldr < newr Then
With Worksheets("rating")
.Range(Cells(4, 2), Cells(4, width + 1)).Copy .Range(Cells(5, 2),
Cells(newr + 3, 2))
End With

With Worksheets("output")
.Range(Cells(4, 3), Cells(4, width + 1)).Copy .Range(Cells(5, 3),
Cells(newr + 3, 3))
End With
End If

End Sub
 
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



All times are GMT +1. The time now is 08:03 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"