Input box, ved ind tastning i kolonne 8 (H)
Dato, bruger og kommentar i celle, vælges cellen senere,
ny linje i celle, og der tilføjes Dato, bruger og kommentar.
Prøv i et tomt Ark.
Kopier koden her under:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect(Target, Columns(8)) Is Nothing Then
Dim userInput As String
On Error GoTo Fejl:
If Not ActiveCell = "" Then
userInput = InputBox("Skriv dit input her:" & vbLf & _
vbLf & "Teksten vil blive tilføjet under:" & vbLf & _
vbLf & ActiveCell, "Skriv her")
If userInput = vbNullString Then Exit Sub
userInput = ActiveCell & Chr(10) & _
Format(Date, "dd.mm.yy") & " " & Application.UserName & " " & userInput
ActiveCell.Value = userInput
GoTo Indsæt:
End If
userInput = InputBox("Skriv dit input her:", "Skriv her")
If userInput = vbNullString Then Exit Sub
userInput = Format(Date, "dd.mm.yy") & " " & Application.UserName & " " & userInput
Indsæt:
ActiveCell.Value = userInput
Columns(8).EntireColumn.AutoFit
Exit Sub
Fejl:
MsgBox "Fejl"
End If
End Sub
I Arket, højre-klik på Ark1 nederst, vælg "Vis programkode" tryk Ctrl + V, luk på det røde kryds.
Klik på en celle i kolonne H