Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 121
Default clear contents on linked sheet

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default clear contents on linked sheet

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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default clear contents on linked sheet

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Clear Contents Secret Squirrel Excel Discussion (Misc queries) 1 February 3rd 09 12:37 AM
Combo Boxes linked to Cells will not clear. ClintG Excel Programming 6 May 31st 07 03:25 PM
Macro to clear range contents when cell contents are changed by us Steve E Excel Programming 12 February 22nd 07 09:09 PM
Clear contents Arne Hegefors Excel Programming 3 September 28th 06 05:43 PM
Clear contents if x is not in the row Mighvik Excel Programming 1 October 5th 04 08:14 PM


All times are GMT +1. The time now is 12:07 AM.

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

About Us

"It's about Microsoft Excel"