Basically I'am making a project which is retreiveing data from a database. I want to make function where a employee are able to write a note and should save them in colum L, M, N.
I am having issues with step 1, 2, 3 can anyone help?
When i write in colum E (write note) and clik "save notes" it should;
This is the code i have made :
I am having issues with step 1, 2, 3 can anyone help?
When i write in colum E (write note) and clik "save notes" it should;
- it should take the data from the cell and insert it in A together with the date from colum D.
- It should copy the note and place it in colum L (E-note 1) if that is not empty then go colum M (E-note 2). It should also copy the date from colum D.
- it should delete the note from colum E.
- When i write a new note in the same row it should do step 1, 2 and 3.
This is the code i have made :
VBA Code:
Sub Test()
'Saves note
Application.ScreenUpdating = False
Dim Rng As Range
If [E9999].End(xlUp).Row <= 3 Then Exit Sub 'Will exit sub if column E is empty
Set Rng = Range("E4:E" & [E9999].End(xlUp).Row) 'Defines column E's range to be used
For Each c In Rng
Let i = c.Row
If Not IsEmpty(c) And IsEmpty(c.Offset(, -1)) And IsEmpty(c.Offset(, -3)) Then
Range("A" & i) = Range("E" & i).Value
Range("B" & i) = Application.UserName 'Retreives value from Computer's Username
Range("D" & i) = Format(Now()) 'Datestamp
'Input value in first non empty L, M, or N column
If Range("L" & i) = "" Then
Range("L" & i) = c.Value
ElseIf Range("L" & i) <> "" And Range("M" & i) = "" Then
Range("M" & i) = c.Value
ElseIf Range("L" & i) <> "" And Range("M" & i) <> "" And Range("N" & i) = "" Then
Range("N" & i) = c.Value
Else
End If
End If
Next
Rng.ClearContents 'Deletes values in column E
Application.ScreenUpdating = True
End Sub