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 February 28th, 2013, 04:52 AM
Registered User
 
Join Date: Feb 2013
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Unhappy

Facing the same problem.... not able to automatically run my code on the cell value change.....

PLZ help....

Below is my code

Code:
 
Sub Worksheet_Change(ByVal Target As Range)
    Dim WatchRange As Range
    Dim IntersectRange As Range
    Set WatchRange = Range("A2")
    Set IntersectRange = Intersect(Target, WatchRange)
    If IntersectRange Is Nothing Then
        'Do Nothing
    Else
        Call kri
    End If
End Sub
Sub kri()
   If Range("A2").Value <> "" Then
  x = Range("A2").Value
  y = (Asc(x) + 12) Mod 128
  If y < 32 Then
    y = y + 32
  End If
  Range("B2").Value = Chr(y)
 End If
End Sub
 
Old February 28th, 2013, 05:02 AM
Registered User
 
Join Date: Feb 2013
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I have put private for sub worksheet_change
and also enabled macros for my worksheet.... still not working
 
Old March 3rd, 2013, 10:04 PM
Friend of Wrox
 
Join Date: Sep 2005
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts
Default

Quote:
Originally Posted by anucool View Post
I have put private for sub worksheet_change
and also enabled macros for my worksheet.... still not working
Can you explain if the Worksheet_Change is not getting fired or the Intersect portion is not executed.

I hope you have placed the code in the Sheet where it is intended (e.g., Sheet1 )

Cheers
Shasur
__________________
C# Code Snippets (http://www.dotnetdud.blogspot.com)

VBA Tips &amp; Tricks (http://www.vbadud.blogspot.com)
 
Old March 24th, 2015, 05:15 PM
Registered User
 
Join Date: Mar 2015
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Wink ActiveCell vs. Target

When you are trying to find the cell that you are changing, make sure that you are referencing Target as being your changing cell as opposed to ActiveCell. If you use ActiveCell, it is going to be the ActiveCell after you return the command or tab to the next cell.

ActiveCell.Row when using the Return key will be (1) row below you Target Cell
ActiveCell.Column when using the Tab key will be (1) column to the right of your Target Cell

Use Target.Row or Target.Column
It is already dimensioned as a Range, and it will give you the correct information of the cell that changed in your WatchRange.


Quote:
Originally Posted by tonyrosen View Post
Figured it out ... I was "finding" the wrong cells. My "active" cell was REALLY the desired "active" cell plus one ... Here is the piece I fixed:

    MyRow = ActiveCell.Row
    'This is the Stop Date Column Number
    MyColumn = ActiveCell.Column - 1
    'This is the Start Date Column Number
    MyColumnPrev = MyColumn - 2





Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I check if a cell content has changed SirAldemar Access VBA 2 August 13th, 2008 07:46 AM
How to check whether page data has changed webmahesh JSP Basics 0 December 12th, 2007 04:38 AM
Changing Cell-formating in Excel via VBA Gert VB How-To 4 May 10th, 2005 01:56 PM
How do I get the CHANGED value in a datagrid cell? Ron Howerton VB.NET 2002/2003 Basics 2 December 23rd, 2004 10:51 AM





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