Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 15th, 2008, 12:37 AM
Registered User
 
Join Date: Feb 2008
Location: , , Australia.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Please help!!!!!Private Sub Worksheet_Change

Can someone help me!!!!!!!! Please!!!!!!!!! am a visual basic novice and am trying to building a calculator in excel using the “Worksheet_Change” code but unfortunately its not working properly. So, am seeking some advice…………

What I want:

• The code to perform is an automatic update once a cell has changes.
Lets say when H3=Renewals,
Hide some cells and go to H3 and don’t run the code again unless I type something other than Renewals
It should also let me continue working with the worksheet cells (That’s my main problem the code runs over and over and over again and it doesn’t let me continue)

The code that am using is:

Private Sub Worksheet_Change(ByVal Target As Range)

* First action I want the code to perform

If Range("H3") = "RENEWALS" Then
Range("b37").Select
Sheets("COVER PAGE").Select
Rows("37:43").Select
Selection.EntireRow.Hidden = True
Range("h3").Select
Else
Rows("37:43").Select
Selection.EntireRow.Hidden = False
Range("D7").Select
End If

* Code should stop here and let the user continue till the next if statement

If Range("M26") = "Yes" Then
Range("b76").Select
Sheets("COVER PAGE").Select
Rows("76:77").Select
Selection.EntireRow.Hidden = False
Range("D30").Select

Else
Rows("76:77").Select
Selection.EntireRow.Hidden = True
Range("D30").Select

End If
* Code should stop here and let the user continue till the next if statement

If Range("M24") = "REVISED" Then
Range("a55").Select
Sheets("COVER PAGE").Select
Rows("50:57").Select
Selection.EntireRow.Hidden = False
Rows("55:56").Select
Selection.EntireRow.Hidden = True
Rows("60:66").Select
Selection.EntireRow.Hidden = True

Range("d52").Select

End If

* Code should stop here and let the user continue till the next if statement

'PRINEW SUPER CALCULATIONS
If Range("M24") = "NEW" Then
Range("a52").Select
Sheets("COVER PAGE").Select
Rows("50:57").Select
Selection.EntireRow.Hidden = False
'Hide Row
Rows("53:54").Select
Selection.EntireRow.Hidden = True
'Hide
Rows("60:66").Select
Selection.EntireRow.Hidden = True

' SELECT CELLS AFTER HIDE....
Sheets("COVER PAGE").Select
Range("d52").Select

End If
* Code should stop here and let the user continue till the next if statement

'VICSUPER CALCULATIONS
If Range("M24") = "OTHER(Eg VICSUPER" Then
Range("A62").Select
Sheets("COVER PAGE").Select

Rows("51:66").Select
Selection.EntireRow.Hidden = False
' Hide
Sheets("COVER PAGE").Select
Rows("51:56").Select
Selection.EntireRow.Hidden = True

' SELECT CELLS AFTER HIDE....
Sheets("COVER PAGE").Select
'Range("E62").Select

End If

* Code should stop here and let the user continue till the next if statement

'SERB SUPER CALCULATIONS
If Range("M24") = "SERB" Then
Sheets("COVER PAGE").Select
Rows("50:57").Select
Selection.EntireRow.Hidden = False
'Hide
Rows("51:56").Select
Selection.EntireRow.Hidden = True
'Hide
Rows("60:66").Select
Selection.EntireRow.Hidden = True

' SELECT CELLS AFTER HIDE....
Sheets("COVER PAGE").Select
Range("c80").Select

End If
* Code should stop here and let the user continue till the next if statement

End Sub


Reply With Quote
  #2 (permalink)  
Old March 6th, 2008, 10:35 PM
Friend of Wrox
Points: 3,060, Level: 23
Points: 3,060, Level: 23 Points: 3,060, Level: 23 Points: 3,060, Level: 23
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2005
Location: , , .
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts
Default

VicM

If your intention 'Code should stop here and let the user continue till the next if statement' is to have code wait for the user's input is impossible. The code will get executed sequentially and will allow user interaction only if it executed.

There are couple of workarounds:

1) Have the If's nested to your application logic. So on one execution, it will check all available paths

2) Have 'Exit Sub' statment, if you want to exit from that part and allow the user to continue (type more info)



http://www.dotnetdud.blogspot.com

VBA Tips & Tricks (http://www.vbadud.blogspot.com)
Reply With Quote
Reply


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

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Private Messages ViagraFalls BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 10 October 22nd, 2007 03:48 PM
Worksheet_Change executing selectively lfrench Excel VBA 3 April 3rd, 2007 03:59 PM
Excel Worksheet_Change option mtowle Excel VBA 1 October 21st, 2005 09:27 AM
Using Private Sub cutovoi Excel VBA 0 February 5th, 2004 12:55 PM
How to step into Worksheet_Change Piblon Excel VBA 2 December 17th, 2003 04:11 AM



All times are GMT -4. The time now is 12:42 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.