Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 10th, 2008, 05:00 AM
Registered User
 
Join Date: Jul 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to deepunair84296
Default Need help in VBA excel on validation

Hi Experts

I have a problem. I have 2 columns. The Column 1 is a Drop down with the values as Estimate, Realise and Deploy. I want when a user selects Estimate in Column 1 the value in column 2 should automatically change to Open and when a user selects Realise in Column 1 the value in column 2 should automatically change to In Progress and when a user selects Deploy in Column 1 the value in column 2 should automatically change to Closed.

These validations need to go on till the end of the page (i.e 1 to 65536)

Please help me to get this done.

PS: i am not a programmer.


Regards

Deepu
 
Old July 11th, 2008, 04:13 PM
Friend of Wrox
 
Join Date: Feb 2007
Posts: 163
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Go into code for the spreadsheet that contains the columns.
The code below changes value in column B to value in column C for the row change occurred in.
--------------------------------------------------------
Private Sub Worksheet_Change(ByVal Target As Range)

'Changes value in column C when corresponding value for row in column B changes
  If Target.Column = 1 Then
    If Target.Value = "Estimate" Then Cells(Target.Row, 2).Value = "Open"
    If Target.Value = "Realize" Then Cells(Target.Row, 2).Value = "In Progress"
    If Target.Value = "Deploy" Then Cells(Target.Row, 2).Value = "Closed"
  End If

End Sub
-------------------------------------

Hope this helps.

 
Old July 11th, 2008, 04:23 PM
Authorized User
 
Join Date: Nov 2007
Posts: 48
Thanks: 0
Thanked 4 Times in 4 Posts
Default

deepunair84296,

allenm, nicely done.

Another solution:

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Intersect(Target, Range("A:A")) Is Nothing Then Exit Sub
    If Target.Count > 1 Then Exit Sub
    With Application
        .EnableEvents = False
        .ScreenUpdating = False
    End With
    Select Case Target.Value
        Case ""
            Target.Offset(, 1).Value = ""
        Case "Estimate"
            Target.Offset(, 1).Value = "Open"
        Case "Realise"
            Target.Offset(, 1).Value = "In Progress"
        Case "Deploy"
            Target.Offset(, 1).Value = "Closed"
        Case Else
            Target.Offset(, 1).Value = ""
    End Select
    With Application
        .EnableEvents = True
        .ScreenUpdating = True
    End With
End Sub

Have a great day,
Stan

stanleydgromjr

Windows Vista Business and Excel 2003, 2007.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Code works in Excel VBA but not Access VBA fossx Access VBA 2 May 21st, 2007 08:00 AM
multi validation in excel lucarnold Excel VBA 1 January 22nd, 2007 06:06 AM
Converting excel data to Access using excel VBA ShaileshShinde VB Databases Basics 1 April 26th, 2006 07:57 AM
Excel VBA to SQL & back to VBA edesousa Excel VBA 1 June 1st, 2004 02:39 AM
Validation Probs using VBA socoolbrewster Access 2 March 19th, 2004 06:54 PM





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