Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
The following code was working fine until I uninstalled my printer and
reinstalled it so my offbrand ink cartridges would work. This should have had no bearing on the code since all files were closed when I did the printer thing. However, that was the only change I had made that I can remember. These are the two lines that it does not like. For Each c In Worksheets(1).Range(Cells(2, 3), Cells(lr, 3)) Worksheets(1).Range(Cells(r, 1), Cells(r, 3)).Copy I change the Range references to: Range("$C$2:$C" & lr) and Range("$A" & r & ":$C" & r) respectively and it works fine again. What happened to the other method of Range? Why would it suddenly decide not to recognize that code? Private Sub may_Click() Unload WOListFrm lr = Worksheets(1).Cells(Rows.Count, 1).End(xlUp).Row Worksheets(1).Range("$A$1:$C$1").Copy Worksheets(4).Range("$A$1") Application.CutCopyMode = False stDate = "5/1" stDate = Format(stDate, "m/d") endDate = "5/31" endDate = Format(endDate, "m/d") For Each c In Worksheets(1).Range(Cells(2, 3), Cells(lr, 3)) If Not c Is Nothing Then sRng = c.Address End If If c = stDate And c <= endDate Then r = Range(sRng).Row Worksheets(1).Range(Cells(r, 1), Cells(r, 3)).Copy prepRpt Application.CutCopyMode = False End If Next If Worksheets(4).Range("$A2") = "" Then TitleScrn MsgBox "NO WORK ORDERS TO REPORT.", , "ADVISORY" Worksheets(4).Cells.Clear Exit Sub End If Worksheets(4).PrintOut Worksheets(4).Cells.Clear Worksheets(4).Columns.UseStandardWidth = True MsgBox "Report has printed", vbInformation, "ADVISORY" End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Explanation of when & how to use ( ) { } : ; , ! etc? | New Users to Excel | |||
Formula Explanation Please | Excel Discussion (Misc queries) | |||
Comma explanation | Excel Worksheet Functions | |||
Formula Explanation | Excel Programming | |||
Explanation of code | Excel Programming |