martinrusten
New member
- Joined
- Mar 17, 2019
- Messages
- 2
- Reaction score
- 0
- Points
- 0
- Excel Version(s)
- 2018
vba find date and enter UserForm text box
hello, i have a list where vba need to find the date in sheets and also the machine name then paste the userform text box
userform works but it do not paste any info.
i have played around with this a few days and can not figure how to make it work, i really hope someone here can help with this
the code that do not work is here:
thank you
hello, i have a list where vba need to find the date in sheets and also the machine name then paste the userform text box
userform works but it do not paste any info.
i have played around with this a few days and can not figure how to make it work, i really hope someone here can help with this
the code that do not work is here:
Code:
[COLOR=#000000][FONT='inherit']Private Sub CommandButton1_Click()
Dim arr, Dat As Date, Mon$, rng As Range, mch As Range, mch1$, clm&
arr = Array("Januar", "Februar", "Mars", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Desember")
Dat = Sheets("Dayplan").Cells(r, 3)
mch1 = Sheets("Dayplan").Cells(r, 4)
Mon = arr(Month(Dat) - 1)[/FONT][/COLOR]
[COLOR=#000000][FONT='inherit']With Sheets(Mon)
Set rng = .Rows(3).Find(Dat, lookat:=xlWhole)
If Not rng Is Nothing Then
Set mch = .Columns(1).Find(mch1, lookat:=xlWhole)
If Not mch Is Nothing Then
TextBox1 = .Cells(mch.Row, rng.Column + 1)
TextBox2 = Format(.Cells(mch.Row, rng.Column + 2), "d/m/yy")
TextBox3 = .Cells(mch.Row, rng.Column + 3)
End If
MsgBox "can not find machine"
End If
MsgBox "can not find date"
End With
Me.Hide
End Sub[/FONT][/COLOR]
thank you