Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
WinXP Pro MSOffice 2003
I am trying to use the following procedure to clear both worksheets so they are ready to produce a fresh report. These worksheets are linked together on one column, so I need to clear Sheet3 first to break the links so that I can clear Sheet1. The second part of the procedure clears sheet1 just fine except it can't clear the linked col because data is still in that col on sheet3. The problem is when I step into the procedure and go thru the first part which is to clear sheet3, it gives me an error (application-defined or object-defined error) on the 'cells.select' line and stops. I recorded a macro to get the code for selecting the entire sheet, and 'cells.select' is what recorded. Clearly I am missing something here, but I haven't a clue what it might be. Could someone please give me a nudge? BTW, this procedure is a macro applied to a button on sheet1 Public Sub Clear() ' Clear Worksheet values for next report Sheet3.Activate Cells.Select Selection.ClearContents Sheet1.Activate Sheets("Sheet1").Select Rows("15:65").Select Range("A65").Activate Selection.SpecialCells(xlCellTypeConstants).Select Selection.ClearContents End Sub Thank you Joanne |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
should have been
sheet3.usedrange.clearcontents sheet1.Rows("15:65").SpecialCells(xlCellTypeConsta nts).ClearContents -- Don Guillett Microsoft MVP Excel SalesAid Software "Don Guillett" wrote in message ... Try this from anywhere in the workbook withOUT selections. Sub clearshts() sheet1.usedrange.clearcontents sheet3.Rows("15:65").SpecialCells(xlCellTypeConsta nts).ClearContents End Sub -- Don Guillett Microsoft MVP Excel SalesAid Software "Joanne" wrote in message ... WinXP Pro MSOffice 2003 I am trying to use the following procedure to clear both worksheets so they are ready to produce a fresh report. These worksheets are linked together on one column, so I need to clear Sheet3 first to break the links so that I can clear Sheet1. The second part of the procedure clears sheet1 just fine except it can't clear the linked col because data is still in that col on sheet3. The problem is when I step into the procedure and go thru the first part which is to clear sheet3, it gives me an error (application-defined or object-defined error) on the 'cells.select' line and stops. I recorded a macro to get the code for selecting the entire sheet, and 'cells.select' is what recorded. Clearly I am missing something here, but I haven't a clue what it might be. Could someone please give me a nudge? BTW, this procedure is a macro applied to a button on sheet1 Public Sub Clear() ' Clear Worksheet values for next report Sheet3.Activate Cells.Select Selection.ClearContents Sheet1.Activate Sheets("Sheet1").Select Rows("15:65").Select Range("A65").Activate Selection.SpecialCells(xlCellTypeConstants).Select Selection.ClearContents End Sub Thank you Joanne |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Clear Contents | Excel Discussion (Misc queries) | |||
Combo Boxes linked to Cells will not clear. | Excel Programming | |||
Macro to clear range contents when cell contents are changed by us | Excel Programming | |||
Clear contents | Excel Programming | |||
Clear contents if x is not in the row | Excel Programming |