How to get entering data with VBA

Useful

Active Member
Joined
Mar 16, 2011
Messages
494
I've range from A2:D10
A2 is "Status I" head of list ; B2 is Status II head of list
C2 is "Date (Status I)" head of list ; D2 is "Date (Status II)" head of list


From A2:A10 I'm entering "Yes" or "No"
From B2:B10 entering "Cheched" or "Not Cheched"

Now I want to get date at C3 when entering A3 "Yes" or "No"
also when entering B3 "Cheched" or "Not Cheched" to get the info at D3 entering data with VBA
I really appreciate your work!
Thanks in advance
 
Last edited:

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Try this: right click the sheet tab, select View Code and paste in

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column < 3 Then
    Application.EnableEvents = False
    Target.Offset(, 2).Value = Date
    Application.EnableEvents = True
End If
End Sub
 
Upvote 0
Try this: right click the sheet tab, select View Code and paste in

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column < 3 Then
    Application.EnableEvents = False
    Target.Offset(, 2).Value = Date
    Application.EnableEvents = True
End If
End Sub

Ok thanks for your help bu i can't to understand this part
"Target.Column < 3 Then"
can you explain?
 
Upvote 0
Target is the cell where you entered data. Target.Column gives the column number. So if you write something in column 1 (A) or 2 (B) it writes the date two columns to the right.
 
Upvote 0
Target is the cell where you entered data. Target.Column gives the column number. So if you write something in column 1 (A) or 2 (B) it writes the date two columns to the right.

I've another list wich columns wich entering to column (15) O, and column (16) P
and date will placed to R and S columns
then i changed the code to (for one column (19) R )

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column >15 Then
Application.EnableEvents = False
Target.Offset(, 3).Value = Date
Application.EnableEvents = True
End If
End Sub

is this right i'm not sure it doesnt works
can you explain more?
Thanks!
 
Last edited:
Upvote 0
Try

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column < 3 Then
    Application.EnableEvents = False
    Target.Offset(, 2).Value = Date
    Application.EnableEvents = True
ElseIf Target.Column = 15 Or Target.Column = 16 Then
    Application.EnableEvents = False
    Target.Offset(, 3).Value = Date
    Application.EnableEvents = True
End If
End Sub
 
Upvote 0
Try

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column < 3 Then
    Application.EnableEvents = False
    Target.Offset(, 2).Value = Date
    Application.EnableEvents = True
ElseIf Target.Column = 15 Or Target.Column = 16 Then
    Application.EnableEvents = False
    Target.Offset(, 3).Value = Date
    Application.EnableEvents = True
End If
End Sub
Thanks for quick reply i'll try it
 
Upvote 0
Try

THANKS I use this part of code
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 15 Or Target.Column = 16 Then
Application.EnableEvents = False
Target.Offset(, 3).Value = Date
Application.EnableEvents = True
End If
End Sub

Your answer abd advice was very helpfull!
Thanks for everithing!
 
Upvote 0

Forum statistics

Threads
1,224,583
Messages
6,179,672
Members
452,937
Latest member
Bhg1984

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top