Solved

Reset a Range

Posted on 2013-12-29
5
215 Views
Last Modified: 2013-12-30
Hi All,

I am trying to do a "reset" every time I open a workbook.  Specifically I would like the worksheet ("BegDay") to do the following in the range J10:J1000

'Place the number 1,000,000 in each and every cell of the range of J10:J1000
'Then immediately place "" in each and every cell of the range of J10:J1000


This should happen every single time the work book opens.

Any ideas?

thanks,
0
Comment
Question by:BostonBob
  • 3
  • 2
5 Comments
 
LVL 80

Expert Comment

by:byundt
Comment Utility
I'm a little confused by why you first want to set all the cells in the specified range to 1,000,000 and then to "".

Nevertheless, the following macro does that. Note that statements 3 and 4 in the snippet below are two alternative ways of clearing the values in J10J1000. The first one puts two double quotes in those cells. The second removes all values.

Put the following code in ThisWorkbook code pane. It won't work at all if installed anywhere else.
Private Sub Workbook_Open()
Worksheets("BegDay").Range("J10:J1000").Value = 1000000
Worksheets("BegDay").Range("J10:J1000").Value = """"        'What you asked for
'Worksheets("BegDay").Range("J10:J1000").ClearContents       'What I think you need instead
End Sub

Open in new window

0
 

Author Comment

by:BostonBob
Comment Utility
Thanks for that byundt.

Not quite what I need.  I am doing a "persistent max and min" function and need this to be a tweaked a bit more.

I put your code above in it didn't work.

I think what I need is for:

Worksheets("BegDay").Range("J10:J1000").Value = 1000000

....to fill down the range first....and then for....

Worksheets("BegDay").Range("J10:J1000").ClearContents

....to fill down the range after each cell has a 1000000 in it.  Maybe this can be accomplished by a 15 second delay?  

thoughts?

thanks,
0
 
LVL 80

Accepted Solution

by:
byundt earned 500 total points
Comment Utility
OK. Here is code with a 15 second delay:
'Put the following two subs in ThisWorkbook code pane. They won't work at all if installed anywhere else!
Private Sub Workbook_Open()
Worksheets("BegDay").Range("J10:J1000").Value = 1000000
Application.OnTime Now + TimeSerial(0, 0, 15), "ThisWorkbook.ClearCells"
End Sub

Private Sub ClearCells()
Worksheets("BegDay").Range("J10:J1000").ClearContents       'What I think you need instead
End Sub

Open in new window

0
 

Author Comment

by:BostonBob
Comment Utility
Precisely Perfect!!!  Thanks so much and Happy New Year!!!
0
 

Author Closing Comment

by:BostonBob
Comment Utility
Just Awesome!
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

No matter the version of Windows you are using, you may have some problems with Windows Search running too slow or possibly not running at all. Before jumping into how you can solve this issue, just know there are many other viable alternative deskt…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

772 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now