Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Shawn
 
Posts: n/a
Default Automatically Put a Value in a specific cell.

Here is what I have:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Application.Intersect(Range("S7:S37"), Target) Is Nothing Then
Worksheets("Daily Log of Students Seen").Range("S38").Value =
ActiveCell.Value
End If
End Sub

But, this causes Cell S38 to equal the cell in the target range that is
entered. I actually want something else to happen. Once I intercept a cell
in the target range and change it, I want Cell S38 to take the value of the
changed cell once I exit it.


--
Thanks
Shawn
  #2   Report Post  
Dave Peterson
 
Posts: n/a
Default

If you want S38 of the daily log sheet to change, maybe using the
worksheet_change event would be a better choice:

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count 1 Then Exit Sub 'ok if more than one cell changed?

On Error GoTo ErrHandler:
If Intersect(Me.Range("S7:S37"), Target) Is Nothing Then
'do nothing
Else
Application.EnableEvents = False
Worksheets("Daily Log of Students Seen").Range("S38").Value _
= Target.Value
End If

ErrHandler:
Application.EnableEvents = True

End Sub


I'm guessing that "daily log" and the current sheet are different. If they're
not, then maybe:

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count 1 Then Exit Sub 'ok if more than one cell changed?

On Error GoTo ErrHandler:
If Intersect(Me.Range("S7:S37"), Target) Is Nothing Then
'do nothing
Else
Application.EnableEvents = False
Me.Range("S38").Value = Target.Value
End If

ErrHandler:
Application.EnableEvents = True

End Sub


Shawn wrote:

Here is what I have:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Application.Intersect(Range("S7:S37"), Target) Is Nothing Then
Worksheets("Daily Log of Students Seen").Range("S38").Value =
ActiveCell.Value
End If
End Sub

But, this causes Cell S38 to equal the cell in the target range that is
entered. I actually want something else to happen. Once I intercept a cell
in the target range and change it, I want Cell S38 to take the value of the
changed cell once I exit it.

--
Thanks
Shawn


--

Dave Peterson
  #3   Report Post  
Gord Dibben
 
Posts: n/a
Default

Shawn

Don't use selectionchange but simply change event and Target.Value

Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Application.Intersect(Range("S7:S37"), Target) Is Nothing Then
Worksheets("Daily Log of Students Seen").Range("S38").Value = _
Target.Value
End If
ws_exit:
Application.EnableEvents = True
End Sub


Gord Dibben Excel MVP

On Mon, 23 May 2005 10:10:48 -0700, "Shawn"
wrote:

Here is what I have:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Application.Intersect(Range("S7:S37"), Target) Is Nothing Then
Worksheets("Daily Log of Students Seen").Range("S38").Value =
ActiveCell.Value
End If
End Sub

But, this causes Cell S38 to equal the cell in the target range that is
entered. I actually want something else to happen. Once I intercept a cell
in the target range and change it, I want Cell S38 to take the value of the
changed cell once I exit it.


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Edit cell automatically takes you to cell cgrant Excel Worksheet Functions 1 May 20th 05 04:30 PM
up to 7 functions? ALex Excel Worksheet Functions 10 April 12th 05 06:42 PM
Using VB, specific cell data into email subject andrew Excel Discussion (Misc queries) 1 January 26th 05 05:53 PM
How do I insert an image into a specific cell within a protected . Scott Peebles Excel Discussion (Misc queries) 1 January 7th 05 01:14 AM
GET.CELL Biff Excel Worksheet Functions 2 November 24th 04 07:16 PM


All times are GMT +1. The time now is 09:43 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"