Welcome to the { mindfrost82.com } forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.

Go Back   { mindfrost82.com } > Gadget Corner > Tech Newsgroups > Microsoft > MS Office > Excel

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-03-2008, 11:40 AM
ChrisAmies@gmail.com
 
Posts: n/a
Controlling Excel Automatic Calculation???

Hi

I’m trying to make a simple routine in excel VB so, when a command
button is pressed, the whole workbook is calculated (I have automatic
calculation set to manual). I also want to display a warning message
to the end user when input data is changed but the “calculate” button
has not been pressed.

Can anyone point me in the right direction?

Any help would be very much appreciated.
Reply With Quote
  #2 (permalink)  
Old 09-03-2008, 11:53 AM
ricardo.rietveld@gmail.com
 
Posts: n/a
Re: Controlling Excel Automatic Calculation???

It is never a good idea to set calculation to manual. nevertheless,
this is a normal setting. Put the following code in the Command Button
Click function

With Application
.Calculation = xlAutomatic
End With

Gr,
Ricardo
Reply With Quote
  #3 (permalink)  
Old 09-03-2008, 11:59 AM
ChrisAmies@gmail.com
 
Posts: n/a
Re: Controlling Excel Automatic Calculation???

Could you give me any pointers on how to display a warning message if
the “calculate” button has not be pressed but input data has
changed??

Reply With Quote
  #4 (permalink)  
Old 09-03-2008, 05:29 PM
Rick Rothstein
 
Posts: n/a
Re: Controlling Excel Automatic Calculation???

I would consider changing the color of the text in the CommandButton as a
warning to the user that the sheet needs to be recalculated (for example,
red text warns the user the sheet need calculating, black text means it
doesn't). To do this, set the text to black in the CommandButton's Click
event and set the text to red in the worksheet's Change event. How you set
the color depends on where the CommandButton came from.

From the Forms toolbar
========================
With Worksheets("Sheet1")
.Shapes("Button 1").TextFrame.Characters.Font.Color = vbRed
End With

From the Control Toolbox toolbar
==================================
With Worksheets("Sheet1")
.CommandButton1.ForeColor = vbRed
End With

You can use the predefined constant vbBlack to make the text black again.

--
Rick (MVP - Excel)


<ChrisAmies@gmail.com> wrote in message
news:bacce0df-ab1f-4ac5-b2cb-d9cc3c1b04c4@e39g2000hsf.googlegroups.com...
Could you give me any pointers on how to display a warning message if
the “calculate” button has not be pressed but input data has
changed??

Reply With Quote
  #5 (permalink)  
Old 09-05-2008, 03:45 PM
ChrisAmies@gmail.com
 
Posts: n/a
Re: Controlling Excel Automatic Calculation???

Hi

I’ve put together the following routine. It basically does what I
originally wanted. I’ve also added code to make sure the “warning”
sub routine is only run on the 1st change of the monitored range of
cells.

I’m having problems when a group of cells are changed in one go (i.e.
a selection). This results in the “warning” sub routine being run for
however many cells are originally selected and changed.

I’m really new to Excel VBA, can anyone offer any suggestions?

CODE:

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Dim VRange As Range
Dim Error_run As String
Dim myRange As Range

Error_run = Range("$Z$1").Value
Set myRange = ActiveCell
Set VRange = Range("custom_pipe")

'Check for sheet changes
For Each cell In Target
If Union(cell, VRange).Address = VRange.Address Then
If Error_run = "YES" Then

Exit Sub

Else

'Run Warning Sub
warning

Sheets("pipe data").Activate
Range("$Z$1").Value = "YES"
myRange.Select

End If
End If
Next cell

Sheets("pipe data").Activate
myRange.Select

End Sub
Reply With Quote
  #6 (permalink)  
Old 09-05-2008, 04:10 PM
Rick Rothstein
 
Posts: n/a
Re: Controlling Excel Automatic Calculation???

I think this will do what you want... remove the warning from inside the
loop and add this code immediately before the For..Next statement (so it run
before the loop starts)...

If Error_run <> "YES" And Not Intersect(Target, VRange) Is Nothing Then
' Run Warning Sub
warning
End If

Also, if I understand it correctly, this line...

If Union(cell, VRange).Address = VRange.Address Then

is usually written like this...

If Not Intersect(cell, VRange) Is Nothing Then

--
Rick (MVP - Excel)


<ChrisAmies@gmail.com> wrote in message
news:4032c9f1-8a11-433a-8b79-490bc07ab4f1@e39g2000hsf.googlegroups.com...
Hi

I’ve put together the following routine. It basically does what I
originally wanted. I’ve also added code to make sure the “warning”
sub routine is only run on the 1st change of the monitored range of
cells.

I’m having problems when a group of cells are changed in one go (i.e.
a selection). This results in the “warning” sub routine being run for
however many cells are originally selected and changed.

I’m really new to Excel VBA, can anyone offer any suggestions?

CODE:

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Dim VRange As Range
Dim Error_run As String
Dim myRange As Range

Error_run = Range("$Z$1").Value
Set myRange = ActiveCell
Set VRange = Range("custom_pipe")

'Check for sheet changes
For Each cell In Target
If Union(cell, VRange).Address = VRange.Address Then
If Error_run = "YES" Then

Exit Sub

Else

'Run Warning Sub
warning

Sheets("pipe data").Activate
Range("$Z$1").Value = "YES"
myRange.Select

End If
End If
Next cell

Sheets("pipe data").Activate
myRange.Select

End Sub

Reply With Quote
Reply

  { mindfrost82.com } > Gadget Corner > Tech Newsgroups > Microsoft > MS Office > Excel


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 05:54 PM.


Powered by vBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.
© 1999-2008 mindfrost82.com v11.0


Sponsors:
Buy Anything On eBay | Buy Anything On eBay | Mortgages | Myspace Comments | Mortgage Calculator



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114