Problems with vb in excel

  • Thread starter Thread starter Johnsey
  • Start date Start date
J

Johnsey

I've been trying to get these to work in excel but i'm not having muc
luck can anyone point me in the right direction. I've put the cod
into vb editor now what do i do?

Private Sub Worksheet_Change(ByVal Target As Range)
Range("A" & Target.Row) = Now()
End Sub

-----------

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 1 Then
Range("C" & Target.Row).Value = Now()
End If
End Sub

I'm trying 2 date stamp a cell when the cell next to it = yes but
want it as a fixed date all the other ways i tried the date would aut
update

F2 is the column with yes in
G2 is the column i want the dates i
 
Hi
you have to put this code in your worksheet module (not in a stadard
module). Also change them to:

Private Sub Worksheet_Change(ByVal Target As Range)
application.enableevents=false
Range("A" & Target.Row) = Now()
application.enableevents=true
End Sub

-----------

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 1 Then
application.enableevents=false
Range("C" & Target.Row).Value = Now()
End If
application.enableevents=true
End Sub
 
John,

This code will put the date in column A if a change is made to B1:B100

Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("B1:B100")) Is Nothing Then
With Target
.Offset(0, -1).Value = Format(Date, "dd mmm yyyy")
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top