PC Review


Reply
 
 
JeffK
Guest
Posts: n/a
 
      24th Mar 2010
I've used this Macro and need to tweak it:

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
With Target
If .Count > 1 Then Exit Sub
If Not Intersect(Range("a10"), .Cells) Is Nothing Then
Application.EnableEvents = False
With Me.Range("b10")
.NumberFormat = "dd mmm yyyy"
.Value = Now
End With
Application.EnableEvents = True
End If
End With
End Sub

This macro stamps B10 if something is entered in A10 but I also want this to
continue to row 1000. Any help would be appreciated
 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      24th Mar 2010
Try:

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
With Target
If .cells.Count > 1 Then
Exit Sub
end if

If Intersect(me.Range("a10:1000"), .Cells) Is Nothing Then
'do nothing
else
Application.EnableEvents = False
With .offset(0,1)
.NumberFormat = "dd mmm yyyy"
.Value = Now
End With
Application.EnableEvents = True
End If
End With
End Sub


I made some completely arbitrary changes (a block if/then instead of the single
line if/then). And I changed the "if .. is nothing" to something I find easier
to understand <vbg>.

If you want, you can change back. It shouldn't be too difficult.


JeffK wrote:
>
> I've used this Macro and need to tweak it:
>
> Private Sub Worksheet_Change(ByVal Target As Excel.Range)
> With Target
> If .Count > 1 Then Exit Sub
> If Not Intersect(Range("a10"), .Cells) Is Nothing Then
> Application.EnableEvents = False
> With Me.Range("b10")
> .NumberFormat = "dd mmm yyyy"
> .Value = Now
> End With
> Application.EnableEvents = True
> End If
> End With
> End Sub
>
> This macro stamps B10 if something is entered in A10 but I also want this to
> continue to row 1000. Any help would be appreciated


--

Dave Peterson
 
Reply With Quote
 
JeffK
Guest
Posts: n/a
 
      25th Mar 2010
I pasted your code and the following error occured:

Method 'Range' of object'_Worksheet'failed

and highlighted

If Intersect(Me.Range("a10:1000"), .Cells) Is Nothing Then


"Dave Peterson" wrote:

> Try:
>
> Private Sub Worksheet_Change(ByVal Target As Excel.Range)
> With Target
> If .cells.Count > 1 Then
> Exit Sub
> end if
>
> If Intersect(me.Range("a10:1000"), .Cells) Is Nothing Then
> 'do nothing
> else
> Application.EnableEvents = False
> With .offset(0,1)
> .NumberFormat = "dd mmm yyyy"
> .Value = Now
> End With
> Application.EnableEvents = True
> End If
> End With
> End Sub
>
>
> I made some completely arbitrary changes (a block if/then instead of the single
> line if/then). And I changed the "if .. is nothing" to something I find easier
> to understand <vbg>.
>
> If you want, you can change back. It shouldn't be too difficult.
>
>
> JeffK wrote:
> >
> > I've used this Macro and need to tweak it:
> >
> > Private Sub Worksheet_Change(ByVal Target As Excel.Range)
> > With Target
> > If .Count > 1 Then Exit Sub
> > If Not Intersect(Range("a10"), .Cells) Is Nothing Then
> > Application.EnableEvents = False
> > With Me.Range("b10")
> > .NumberFormat = "dd mmm yyyy"
> > .Value = Now
> > End With
> > Application.EnableEvents = True
> > End If
> > End With
> > End Sub
> >
> > This macro stamps B10 if something is entered in A10 but I also want this to
> > continue to row 1000. Any help would be appreciated

>
> --
>
> Dave Peterson
> .
>

 
Reply With Quote
 
JeffK
Guest
Posts: n/a
 
      25th Mar 2010
Never mind Dave I discovered the solution (a10:a1000)

Thanks for the help, you're always a great resource.

"Dave Peterson" wrote:

> Try:
>
> Private Sub Worksheet_Change(ByVal Target As Excel.Range)
> With Target
> If .cells.Count > 1 Then
> Exit Sub
> end if
>
> If Intersect(me.Range("a10:1000"), .Cells) Is Nothing Then
> 'do nothing
> else
> Application.EnableEvents = False
> With .offset(0,1)
> .NumberFormat = "dd mmm yyyy"
> .Value = Now
> End With
> Application.EnableEvents = True
> End If
> End With
> End Sub
>
>
> I made some completely arbitrary changes (a block if/then instead of the single
> line if/then). And I changed the "if .. is nothing" to something I find easier
> to understand <vbg>.
>
> If you want, you can change back. It shouldn't be too difficult.
>
>
> JeffK wrote:
> >
> > I've used this Macro and need to tweak it:
> >
> > Private Sub Worksheet_Change(ByVal Target As Excel.Range)
> > With Target
> > If .Count > 1 Then Exit Sub
> > If Not Intersect(Range("a10"), .Cells) Is Nothing Then
> > Application.EnableEvents = False
> > With Me.Range("b10")
> > .NumberFormat = "dd mmm yyyy"
> > .Value = Now
> > End With
> > Application.EnableEvents = True
> > End If
> > End With
> > End Sub
> >
> > This macro stamps B10 if something is entered in A10 but I also want this to
> > continue to row 1000. Any help would be appreciated

>
> --
>
> Dave Peterson
> .
>

 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      25th Mar 2010
Sorry about the typo.

Gald <vbg> you found it.

JeffK wrote:
>
> Never mind Dave I discovered the solution (a10:a1000)
>
> Thanks for the help, you're always a great resource.
>
> "Dave Peterson" wrote:
>
> > Try:
> >
> > Private Sub Worksheet_Change(ByVal Target As Excel.Range)
> > With Target
> > If .cells.Count > 1 Then
> > Exit Sub
> > end if
> >
> > If Intersect(me.Range("a10:1000"), .Cells) Is Nothing Then
> > 'do nothing
> > else
> > Application.EnableEvents = False
> > With .offset(0,1)
> > .NumberFormat = "dd mmm yyyy"
> > .Value = Now
> > End With
> > Application.EnableEvents = True
> > End If
> > End With
> > End Sub
> >
> >
> > I made some completely arbitrary changes (a block if/then instead of the single
> > line if/then). And I changed the "if .. is nothing" to something I find easier
> > to understand <vbg>.
> >
> > If you want, you can change back. It shouldn't be too difficult.
> >
> >
> > JeffK wrote:
> > >
> > > I've used this Macro and need to tweak it:
> > >
> > > Private Sub Worksheet_Change(ByVal Target As Excel.Range)
> > > With Target
> > > If .Count > 1 Then Exit Sub
> > > If Not Intersect(Range("a10"), .Cells) Is Nothing Then
> > > Application.EnableEvents = False
> > > With Me.Range("b10")
> > > .NumberFormat = "dd mmm yyyy"
> > > .Value = Now
> > > End With
> > > Application.EnableEvents = True
> > > End If
> > > End With
> > > End Sub
> > >
> > > This macro stamps B10 if something is entered in A10 but I also want this to
> > > continue to row 1000. Any help would be appreciated

> >
> > --
> >
> > Dave Peterson
> > .
> >


--

Dave Peterson
 
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
Separating date from a Date & Time stamp =?Utf-8?B?SlQ=?= Microsoft Excel Misc 9 10th Jun 2008 05:55 PM
Date Created or Date Modified Record Stamp =?Utf-8?B?Um9zZQ==?= Microsoft Access 1 13th May 2007 07:24 PM
Create a button that will date stamp todays date in a cell Tom Meacham Microsoft Excel Misc 3 11th Jan 2006 01:08 AM
Date stamp spreadsheet in excel to remind me of completion date =?Utf-8?B?QmlnIGZlbGxh?= Microsoft Excel Worksheet Functions 1 18th Oct 2005 04:10 PM
date stamp Can I add a date stamp in a Text or Memo Field =?Utf-8?B?TWljaGFlbCBM?= Microsoft Access Database Table Design 10 11th Apr 2005 02:29 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:43 AM.