PC Review


Reply
 
 
ranswert
Guest
Posts: n/a
 
      16th Jan 2008
I have the following code:
Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo stoppit
Application.EnableEvents = False
With Me.Range("drw1inforng")
If .Value <> "" Then
MsgBox ("")
End If
End With
stoppit:
Application.EnableEvents = True

End Sub

'drw1inforng' is a named range on my sheet. When I make a change in this
range, nothing happens. What am I doing wrong here?
Thanks
 
Reply With Quote
 
 
 
 
Mike H
Guest
Posts: n/a
 
      16th Jan 2008
What would you like to happen?

The code executes when any cell on the sheet changes but your don't tell it
to do anything. Here's a guess that does something and may get you going:-

Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo stoppit
Application.EnableEvents = False
For Each c In Range("drw1inforng")
If c.Value <> "" Then
MsgBox c.Value
End If
Next
stoppit:
Application.EnableEvents = True
End Sub

Mike

"ranswert" wrote:

> I have the following code:
> Private Sub Worksheet_Change(ByVal Target As Range)
> On Error GoTo stoppit
> Application.EnableEvents = False
> With Me.Range("drw1inforng")
> If .Value <> "" Then
> MsgBox ("")
> End If
> End With
> stoppit:
> Application.EnableEvents = True
>
> End Sub
>
> 'drw1inforng' is a named range on my sheet. When I make a change in this
> range, nothing happens. What am I doing wrong here?
> Thanks

 
Reply With Quote
 
ranswert
Guest
Posts: n/a
 
      16th Jan 2008
I am looking for a way to run a macro when a cell in a range is changed. I
used the code that you suggested and each time a cell is changed, it goes
thru all the cells in that range. i only need it to work on the cell that is
change within a range of cells. How do I do this?
Thanks

"Mike H" wrote:

> What would you like to happen?
>
> The code executes when any cell on the sheet changes but your don't tell it
> to do anything. Here's a guess that does something and may get you going:-
>
> Private Sub Worksheet_Change(ByVal Target As Range)
> On Error GoTo stoppit
> Application.EnableEvents = False
> For Each c In Range("drw1inforng")
> If c.Value <> "" Then
> MsgBox c.Value
> End If
> Next
> stoppit:
> Application.EnableEvents = True
> End Sub
>
> Mike
>
> "ranswert" wrote:
>
> > I have the following code:
> > Private Sub Worksheet_Change(ByVal Target As Range)
> > On Error GoTo stoppit
> > Application.EnableEvents = False
> > With Me.Range("drw1inforng")
> > If .Value <> "" Then
> > MsgBox ("")
> > End If
> > End With
> > stoppit:
> > Application.EnableEvents = True
> >
> > End Sub
> >
> > 'drw1inforng' is a named range on my sheet. When I make a change in this
> > range, nothing happens. What am I doing wrong here?
> > Thanks

 
Reply With Quote
 
SparkyUK
Guest
Posts: n/a
 
      16th Jan 2008
Works fine for me! Good luck.

"ranswert" wrote:

> I have the following code:
> Private Sub Worksheet_Change(ByVal Target As Range)
> On Error GoTo stoppit
> Application.EnableEvents = False
> With Me.Range("drw1inforng")
> If .Value <> "" Then
> MsgBox ("")
> End If
> End With
> stoppit:
> Application.EnableEvents = True
>
> End Sub
>
> 'drw1inforng' is a named range on my sheet. When I make a change in this
> range, nothing happens. What am I doing wrong here?
> Thanks

 
Reply With Quote
 
SparkyUK
Guest
Posts: n/a
 
      16th Jan 2008
Try the UNION method with Target and drw1inforng ranges

"ranswert" wrote:

> I am looking for a way to run a macro when a cell in a range is changed. I
> used the code that you suggested and each time a cell is changed, it goes
> thru all the cells in that range. i only need it to work on the cell that is
> change within a range of cells. How do I do this?
> Thanks
>
> "Mike H" wrote:
>
> > What would you like to happen?
> >
> > The code executes when any cell on the sheet changes but your don't tell it
> > to do anything. Here's a guess that does something and may get you going:-
> >
> > Private Sub Worksheet_Change(ByVal Target As Range)
> > On Error GoTo stoppit
> > Application.EnableEvents = False
> > For Each c In Range("drw1inforng")
> > If c.Value <> "" Then
> > MsgBox c.Value
> > End If
> > Next
> > stoppit:
> > Application.EnableEvents = True
> > End Sub
> >
> > Mike
> >
> > "ranswert" wrote:
> >
> > > I have the following code:
> > > Private Sub Worksheet_Change(ByVal Target As Range)
> > > On Error GoTo stoppit
> > > Application.EnableEvents = False
> > > With Me.Range("drw1inforng")
> > > If .Value <> "" Then
> > > MsgBox ("")
> > > End If
> > > End With
> > > stoppit:
> > > Application.EnableEvents = True
> > >
> > > End Sub
> > >
> > > 'drw1inforng' is a named range on my sheet. When I make a change in this
> > > range, nothing happens. What am I doing wrong here?
> > > Thanks

 
Reply With Quote
 
ranswert
Guest
Posts: n/a
 
      16th Jan 2008
Can you give me an example?

"SparkyUK" wrote:

> Try the UNION method with Target and drw1inforng ranges
>
> "ranswert" wrote:
>
> > I am looking for a way to run a macro when a cell in a range is changed. I
> > used the code that you suggested and each time a cell is changed, it goes
> > thru all the cells in that range. i only need it to work on the cell that is
> > change within a range of cells. How do I do this?
> > Thanks
> >
> > "Mike H" wrote:
> >
> > > What would you like to happen?
> > >
> > > The code executes when any cell on the sheet changes but your don't tell it
> > > to do anything. Here's a guess that does something and may get you going:-
> > >
> > > Private Sub Worksheet_Change(ByVal Target As Range)
> > > On Error GoTo stoppit
> > > Application.EnableEvents = False
> > > For Each c In Range("drw1inforng")
> > > If c.Value <> "" Then
> > > MsgBox c.Value
> > > End If
> > > Next
> > > stoppit:
> > > Application.EnableEvents = True
> > > End Sub
> > >
> > > Mike
> > >
> > > "ranswert" wrote:
> > >
> > > > I have the following code:
> > > > Private Sub Worksheet_Change(ByVal Target As Range)
> > > > On Error GoTo stoppit
> > > > Application.EnableEvents = False
> > > > With Me.Range("drw1inforng")
> > > > If .Value <> "" Then
> > > > MsgBox ("")
> > > > End If
> > > > End With
> > > > stoppit:
> > > > Application.EnableEvents = True
> > > >
> > > > End Sub
> > > >
> > > > 'drw1inforng' is a named range on my sheet. When I make a change in this
> > > > range, nothing happens. What am I doing wrong here?
> > > > Thanks

 
Reply With Quote
 
SparkyUK
Guest
Posts: n/a
 
      16th Jan 2008
Sorry should have used INTERSECT method:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim rngUnion As Range

Set rngUnion = Application.Intersect(Target, Me.Range("drw1inforng"))

If Not (rngUnion Is Nothing) Then
On Error GoTo stoppit
Application.EnableEvents = False
If rngUnion.Value <> "" Then MsgBox ("Not blank")
End If

stoppit:
Application.EnableEvents = True

End Sub

-----

"ranswert" wrote:

> Can you give me an example?
>
> "SparkyUK" wrote:
>
> > Try the UNION method with Target and drw1inforng ranges
> >
> > "ranswert" wrote:
> >
> > > I am looking for a way to run a macro when a cell in a range is changed. I
> > > used the code that you suggested and each time a cell is changed, it goes
> > > thru all the cells in that range. i only need it to work on the cell that is
> > > change within a range of cells. How do I do this?
> > > Thanks
> > >
> > > "Mike H" wrote:
> > >
> > > > What would you like to happen?
> > > >
> > > > The code executes when any cell on the sheet changes but your don't tell it
> > > > to do anything. Here's a guess that does something and may get you going:-
> > > >
> > > > Private Sub Worksheet_Change(ByVal Target As Range)
> > > > On Error GoTo stoppit
> > > > Application.EnableEvents = False
> > > > For Each c In Range("drw1inforng")
> > > > If c.Value <> "" Then
> > > > MsgBox c.Value
> > > > End If
> > > > Next
> > > > stoppit:
> > > > Application.EnableEvents = True
> > > > End Sub
> > > >
> > > > Mike
> > > >
> > > > "ranswert" wrote:
> > > >
> > > > > I have the following code:
> > > > > Private Sub Worksheet_Change(ByVal Target As Range)
> > > > > On Error GoTo stoppit
> > > > > Application.EnableEvents = False
> > > > > With Me.Range("drw1inforng")
> > > > > If .Value <> "" Then
> > > > > MsgBox ("")
> > > > > End If
> > > > > End With
> > > > > stoppit:
> > > > > Application.EnableEvents = True
> > > > >
> > > > > End Sub
> > > > >
> > > > > 'drw1inforng' is a named range on my sheet. When I make a change in this
> > > > > range, nothing happens. What am I doing wrong here?
> > > > > Thanks

 
Reply With Quote
 
ranswert
Guest
Posts: n/a
 
      16th Jan 2008
Thanks I'll give it a try

"SparkyUK" wrote:

> Sorry should have used INTERSECT method:
>
> Private Sub Worksheet_Change(ByVal Target As Range)
> Dim rngUnion As Range
>
> Set rngUnion = Application.Intersect(Target, Me.Range("drw1inforng"))
>
> If Not (rngUnion Is Nothing) Then
> On Error GoTo stoppit
> Application.EnableEvents = False
> If rngUnion.Value <> "" Then MsgBox ("Not blank")
> End If
>
> stoppit:
> Application.EnableEvents = True
>
> End Sub
>
> -----
>
> "ranswert" wrote:
>
> > Can you give me an example?
> >
> > "SparkyUK" wrote:
> >
> > > Try the UNION method with Target and drw1inforng ranges
> > >
> > > "ranswert" wrote:
> > >
> > > > I am looking for a way to run a macro when a cell in a range is changed. I
> > > > used the code that you suggested and each time a cell is changed, it goes
> > > > thru all the cells in that range. i only need it to work on the cell that is
> > > > change within a range of cells. How do I do this?
> > > > Thanks
> > > >
> > > > "Mike H" wrote:
> > > >
> > > > > What would you like to happen?
> > > > >
> > > > > The code executes when any cell on the sheet changes but your don't tell it
> > > > > to do anything. Here's a guess that does something and may get you going:-
> > > > >
> > > > > Private Sub Worksheet_Change(ByVal Target As Range)
> > > > > On Error GoTo stoppit
> > > > > Application.EnableEvents = False
> > > > > For Each c In Range("drw1inforng")
> > > > > If c.Value <> "" Then
> > > > > MsgBox c.Value
> > > > > End If
> > > > > Next
> > > > > stoppit:
> > > > > Application.EnableEvents = True
> > > > > End Sub
> > > > >
> > > > > Mike
> > > > >
> > > > > "ranswert" wrote:
> > > > >
> > > > > > I have the following code:
> > > > > > Private Sub Worksheet_Change(ByVal Target As Range)
> > > > > > On Error GoTo stoppit
> > > > > > Application.EnableEvents = False
> > > > > > With Me.Range("drw1inforng")
> > > > > > If .Value <> "" Then
> > > > > > MsgBox ("")
> > > > > > End If
> > > > > > End With
> > > > > > stoppit:
> > > > > > Application.EnableEvents = True
> > > > > >
> > > > > > End Sub
> > > > > >
> > > > > > 'drw1inforng' is a named range on my sheet. When I make a change in this
> > > > > > range, nothing happens. What am I doing wrong here?
> > > > > > Thanks

 
Reply With Quote
 
Mike H
Guest
Posts: n/a
 
      16th Jan 2008
will this doit

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
If Not Intersect(Target, Range("drw1inforng")) Is Nothing Then
MsgBox Target.Value
End If
End Sub

Mike

"ranswert" wrote:

> I am looking for a way to run a macro when a cell in a range is changed. I
> used the code that you suggested and each time a cell is changed, it goes
> thru all the cells in that range. i only need it to work on the cell that is
> change within a range of cells. How do I do this?
> Thanks
>
> "Mike H" wrote:
>
> > What would you like to happen?
> >
> > The code executes when any cell on the sheet changes but your don't tell it
> > to do anything. Here's a guess that does something and may get you going:-
> >
> > Private Sub Worksheet_Change(ByVal Target As Range)
> > On Error GoTo stoppit
> > Application.EnableEvents = False
> > For Each c In Range("drw1inforng")
> > If c.Value <> "" Then
> > MsgBox c.Value
> > End If
> > Next
> > stoppit:
> > Application.EnableEvents = True
> > End Sub
> >
> > Mike
> >
> > "ranswert" wrote:
> >
> > > I have the following code:
> > > Private Sub Worksheet_Change(ByVal Target As Range)
> > > On Error GoTo stoppit
> > > Application.EnableEvents = False
> > > With Me.Range("drw1inforng")
> > > If .Value <> "" Then
> > > MsgBox ("")
> > > End If
> > > End With
> > > stoppit:
> > > Application.EnableEvents = True
> > >
> > > End Sub
> > >
> > > 'drw1inforng' is a named range on my sheet. When I make a change in this
> > > range, nothing happens. What am I doing wrong here?
> > > Thanks

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Changing the cell format doesn't change existing cell content Kate Microsoft Excel Misc 2 14th Jan 2010 04:44 PM
Need Help, DataGrid, Cell color change on cell data change =?Utf-8?B?QnJpYW5ESA==?= Microsoft C# .NET 0 13th Jun 2007 03:45 PM
Change in DataGrid Cell (combobox) should cause change in another cell (TextBox) joinzulfi@gmail.com Microsoft VB .NET 0 5th Apr 2007 08:00 AM
How to trigger one cell change to change another cell using VB in excel? Please help! :) raytan Microsoft Excel Programming 4 26th Mar 2007 03:49 AM
Worksheet shakes like Rock n' Roll - how check the cell beside upon a singel cell change? Microsoft Excel Misc 1 4th May 2004 07:57 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:05 PM.