?
Solved

Reset a Range

Posted on 2013-12-29
5
Medium Priority
?
231 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 81

Expert Comment

by:byundt
ID: 39745563
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
ID: 39745597
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 81

Accepted Solution

by:
byundt earned 2000 total points
ID: 39746022
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
ID: 39746509
Precisely Perfect!!!  Thanks so much and Happy New Year!!!
0
 

Author Closing Comment

by:BostonBob
ID: 39746510
Just Awesome!
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

This article describes how you can use Custom Document Properties to store settings and other information in your workbook so that they will be available the next time you open the workbook.
Outlook for dependable use in a very small business   This article is about using the Outlook application (part of Microsoft Office) in a very small business, or for homeowners where dependability and reliability are critical requirements. This …
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.

762 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