Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Clear Content of cells

Posted on 2011-02-27
5
Medium Priority
?
594 Views
Last Modified: 2012-06-21
I have my code coping over data from a previoud sheet. now i need the code to clear a differint range of cells
dteToday = InputBox("Enter todays date:")  
Set objPreviousSheet = ActiveSheet  
objPreviousSheet.Copy , ActiveWorkbook.Sheets(ActiveWorkbook.Sheets.Count)  
Set objNewSheet = ActiveWorkbook.Sheets(ActiveWorkbook.Sheets.Count)  
objNewSheet.Name = dteToday  
objPreviousSheet.Range("F11:F16,H11:H16,J11:J16,L11:L16,N11:N16,P11:P16,R11:R16").Copy objNewSheet.Range("AA11:AG16")
objPreviousSheet.Range ("E11:E16,G11:G16,I11:I16,K11:K16,M11:M16,O11:O16,Q11:Q16").ClarContent

Open in new window

0
Comment
Question by:joshuajoseph09
  • 2
5 Comments
 
LVL 59

Expert Comment

by:Chris Bottomley
ID: 34992146
You already seem to have it .. albeit a typo you need clearcontents as the final command in te line

Chris
0
 
LVL 6

Accepted Solution

by:
TinTombStone earned 1000 total points
ID: 34992182
for a particulat range
objPreviousSheet.Range("A1:A10").ClearContents

or for non-adjacent ranges
objPreviousSheet.Range("A1,A3,A4,A10,F45").ClearContents

or  for the whole sheet
objPreviousSheet.Cells.ClearContents

or for the whole used range
objPreviousSheet.UsedRange.Clear

or for the current datarange
objPreviousSheet.ActiveCell.CurrentRegion.ClearContents
0
 
LVL 59

Assisted Solution

by:Chris Bottomley
Chris Bottomley earned 1000 total points
ID: 34992238
Note Clearcontents as you seem to have started with will clear the data whereas .clear will clear the contents and also any formatting applied to the cell.

Chris
0
 
LVL 24

Expert Comment

by:Tracy
ID: 35225366
This question has been classified as abandoned and is being closed as part of the Cleanup Program. See my comment at the end of the question for more details.
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
This article will show how Aten was able to supply easy management and control for Artear's video walls and wide range display configurations of their newsroom.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

885 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question