LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Help with Auto Fill Date

Hello.

I've used a recent code from this group and it's giving me some problems.
Hope you don't mind me asking for your help.

When I run the 'auto date' code, it cancels out my vlookup code and creates
and error. After this happens, all the code in my workbook becomes
inoperable. Can you examine the code I'm using and give me some hints,
please?
---
Private Sub Worksheet_Change(ByVal Target As Range)
<<<<<<The following code runs the vlookup...
Dim rng As Range, res As Variant

If Target.Cells.Count 1 Then Exit Sub
If Intersect(Target, Me.Range("B6:B5000")) Is Nothing Then Exit Sub

Set rng = Worksheets("StatePris").Range("A1:C50000")

res = Application.VLookup(Target, rng, 2, False)

Application.EnableEvents = False
If IsError(res) Then
Target.Offset(0, 1).Resize(1, 2).Value = ""
Else
Target.Offset(0, 1).Value = res
Target.Offset(0, 2).Value = Application.VLookup(Target, rng, 3, False)
Application.EnableEvents = True
End If

<<<<this code runs the auto date
With Target
With Target
If .Count 1 Then Exit Sub
If Not Intersect(Range("B6:B2000"), .Cells) Is Nothing Then
Application.EnableEvents = False
If IsEmpty(.Value) Then
.Offset(0, -1).ClearContents
Else
With .Offset(0, -1)
.NumberFormat = "dd mm yy"
.Value = Now
End With
End If
Application.EnableEvents = True
End If
End With
End Sub


Thanks....
Mark


 
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
AUTO FILL DATE 1ST & 15 lolan7 Excel Discussion (Misc queries) 4 July 17th 12 12:50 AM
Date Auto Fill malewis48 Excel Discussion (Misc queries) 3 January 31st 08 06:16 PM
Auto fill today's date nabanco Excel Programming 4 August 1st 07 05:17 PM
Date auto fill Chris New Users to Excel 2 October 31st 06 09:26 PM
Auto Date Fill-in Dreamweavn via OfficeKB.com Excel Worksheet Functions 2 April 30th 05 09:09 PM


All times are GMT +1. The time now is 03:01 AM.

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

About Us

"It's about Microsoft Excel"