For each cell... VB HELP
Solved/Closed
Related:
- For each cell... VB HELP
- An example of a cell is a blank cell ✓ - Programming Forum
- Clear only the formatting from the selected cell (leaving the content) - Guide
- If cell contains date then return value ✓ - Excel Forum
- Excel "IF" function w/ date in test cell ✓ - Excel Forum
- Excel formula to check if cell contains a date - Excel Forum
3 responses
rizvisa1
Posts
4478
Registration date
Thursday January 28, 2010
Status
Contributor
Last seen
May 5, 2022
766
Mar 11, 2010 at 10:25 AM
Mar 11, 2010 at 10:25 AM
Trowa, I am not sure if "N4" is what you meant or its a typing error. Presuming it is what you want then you can use a loop. I am not sure if worksheet_change is best for this. I think you should use Workbook_BeforeClose. Only time there could be an issue would be if some one was working around mid night :P
Any how, you would know best, here is my solution. Though again, this will be triggred on change. I think you should on do it if only COL A changes as this is when you want your date to be as a value instead of formula.
Target.Column should tell u if the trigger was A column or not
Any how, you would know best, here is my solution. Though again, this will be triggred on change. I think you should on do it if only COL A changes as this is when you want your date to be as a value instead of formula.
Target.Column should tell u if the trigger was A column or not
Private Sub Worksheet_Change(ByVal Target As Range) Application.EnableEvents = False 'if you want to find out the last used cell in column M 'llastrow = Cells(ActiveSheet.Rows.Count, "M").End(xlUp).Row 'in case you want to hard code llastrow = 1040 processrow = 4 Do While (processrow <= llastrow) If (Cells(processrow, "M") <> "") Then Cells(processrow, "N").Value = Cells(processrow, "M").Value End If processrow = processrow + 1 Loop Application.EnableEvents = True End Sub
aquarelle
Posts
7140
Registration date
Saturday April 7, 2007
Status
Moderator
Last seen
March 25, 2024
491
Mar 11, 2010 at 03:05 PM
Mar 11, 2010 at 03:05 PM
Hi ,
Here is an other macro that you could also try :
See you :)
Here is an other macro that you could also try :
Private Sub Worksheet_SelectionChange(ByVal Target As Range) Set MyPlage = Range("A4:A1040") For Each Cell In MyPlage If Cell.Value = "Ja" And Cell.Offset(0, 13).Value = "" Then Cell.Offset(0, 13).FormulaLocal = Format(Now, "dd/mm/yy") End If Next End Sub
See you :)
Wow, this gives me new insight in how to write codes.
Both codes works great.
I thought I had to use two columns; one for the formula and one to copy the value to.
For some reason Aquarelle always seems to know what I need. All I have to do is change the cell.offset(0,13) to (0,12) and I'm done.
Also thanks Rizvisa for providing an understandable (to me) loop code along with your explanation.
This has been a very profitable post for me.
Many thanks for the reply's.
Whishing you both all the best,
Trowa
Both codes works great.
I thought I had to use two columns; one for the formula and one to copy the value to.
For some reason Aquarelle always seems to know what I need. All I have to do is change the cell.offset(0,13) to (0,12) and I'm done.
Also thanks Rizvisa for providing an understandable (to me) loop code along with your explanation.
This has been a very profitable post for me.
Many thanks for the reply's.
Whishing you both all the best,
Trowa