Mrrrr's Forum (VIEW ONLY)
Un forum care ofera solutii pentru unele probleme legate in general de PC. Pe langa solutii, aici puteti gasi si alte lucruri interesante // A forum that offers solutions to some PC related issues. Besides these, here you can find more interesting stuff.
|
Lista Forumurilor Pe Tematici
|
Mrrrr's Forum (VIEW ONLY) | Reguli | Inregistrare | Login
POZE MRRRR'S FORUM (VIEW ONLY)
Nu sunteti logat.
|
Nou pe simpatie: surender_lady Profile
| Femeie 25 ani Arad cauta Barbat 26 - 47 ani |
|
Mrrrr
AdMiN
Inregistrat: acum 17 ani
Postari: 2228
|
|
Source:
I have an excel file in which I want to complete a year's deliveries that are made on a daily basis. I will take a simple example: - assume column A has 5000 rows completed with formula =TODAY() - assume column B is blank now, but at the end of today, it will have 50 cells completed
What I wanted was to get a macro to memorize today in column A if the corresponding cell in column B is completed. And DerbyDad03 from computing.net provided.
This code should be inserted in the code of the sheet. In VBA, right click on the sheet you want it to work on, select View Code and paste it there. This code will run automatically each time you make a change to the sheet.
Private Sub Worksheet_Change(ByVal Target As Range) Dim LastRow As Long Dim c As Range
On Error GoTo CleanExit
'Determine if change was made to Column B If Target.Column = 2 Then Application.EnableEvents = False
'Loop through range, changing Column A as appropriate. For Each c In Range(Target.Address) If c = "" Then Range("A" & c.Row).Formula = "=TODAY()" Else: Range("A" & c.Row) = Range("A" & c.Row).Value End If Next CleanExit: Application.EnableEvents = True End If End Sub |
_______________________________________
|
|
pus acum 6 ani |
|
Mrrrr
AdMiN
Inregistrat: acum 17 ani
Postari: 2228
|
|
Keywords: excel worksheet change
_______________________________________
|
|
pus acum 1 an |
|