View Full Version : Run-time error code "438"
hyudien
07-20-2019, 02:01 PM
Hello master. I'm a new member here and i have a little problem with my code. And forgive me if this trouble already asked by someone before.
Sub cmdpemasukan_Click() Dim Ws As Worksheets
Set Ws = Worksheets("PEMASUKAN") & ("ANGSURAN")
BarisTerakhir = Ws("PEMASUKAN").Cells(Rows.Count, 1).End(xlUp).Row
Ws("ANGSURAN").Range(DU7).Copy Ws("PEMASUKAN").Range(BarisTerakhir + 1, 1)
End Sub
Please help me to reolve this problem
Regards
Hyudien
Paul_Hossler
07-20-2019, 03:36 PM
"Worksheets" is the Collection of all the worksheets
To refer to a single worksheet, it's Worksheets ("Sheet1") or what ever the name is
Sub cmdpemasukan_Click()
Dim ws1 As Worksheet, ws2 as Worksheet
Dim BarisTerakhir As Long
Set ws1 = Worksheets("PEMASUKAN")
Set ws2 = Worksheets ("ANGSURAN")
BarisTerakhir = ws1.Cells(Rows.Count, 1).End(xlUp).Row
ws2.Range(DU7).Copy ws1.Range(BarisTerakhir + 1, 1)
End Sub
hyudien
07-20-2019, 08:16 PM
Thanks for help me. But when i try to run that code than error change to 1004. So, what's wrong?
Bob Phillips
07-21-2019, 03:13 AM
Maybe
Sub cmdpemasukan_Click()
Dim ws1 As Worksheet, ws2 As Worksheet
Dim BarisTerakhir As Long
Set ws1 = Worksheets("PEMASUKAN")
Set ws2 = Worksheets("ANGSURAN")
BarisTerakhir = ws2.Cells(ws2.Rows.Count, 1).End(xlUp).Row
ws2.Range("DU7").Copy ws1.Cells(BarisTerakhir + 1, 1)
End Sub
Paul_Hossler
07-21-2019, 04:38 AM
Thanks for help me. But when i try to run that code than error change to 1004. So, what's wrong?
What line is showing the error?
hyudien
08-17-2019, 11:17 PM
already resolved with another code.
But, i have another one.
Private Sub cmdinput_Click()
With Worksheets("angsuran")
kodenama = Me.ComboBox1.Value
Set NAMA = Cells.Find("kodenama", LookIn:=xlValues)
If Not NAMA Is Nothing Then
kolom = NAMA.Column
End If
KolomKosong = .Cells(NAMA, 1).End(xlToRight).Offset(0, 1).Column
DPTpicker1.Value = Worksheets("angsuran").Cells(KolomKosong).Value
TextBox1 = Worksheets("angsuran").Cells(KolomKosong + 1).Value
End With
End Sub
And always wrong wrong in that code. Can you please help me.
Regards
Hyudien
Artik
08-18-2019, 02:54 AM
Probably
Private Sub cmdinput_Click()
Dim kodenama As String
Dim NAMA As Range
Dim kolom As Long
Dim KolomKosong As Long
kodenama = Me.ComboBox1.Value
With Worksheets("angsuran")
Set NAMA = .Cells.Find(kodenama, LookIn:=xlValues)
If Not NAMA Is Nothing Then
kolom = NAMA.Column
KolomKosong = .Cells(NAMA.Row, 1).End(xlToRight).Offset(0, 1).Column
'Or
'KolomKosong = .Cells(NAMA.Row, kolom).End(xlToRight).Offset(0, 1).Column
DPTpicker1.Value = .Cells(KolomKosong).Value
TextBox1.Value = .Cells(KolomKosong + 1).Value
Else
MsgBox kodenama & " value not found in the sheet", vbExclamation
End If
End With
End Sub
Artik
hyudien
08-18-2019, 08:31 AM
Probably
Private Sub cmdinput_Click()
Dim kodenama As String
Dim NAMA As Range
Dim kolom As Long
Dim KolomKosong As Long
kodenama = Me.ComboBox1.Value
With Worksheets("angsuran")
Set NAMA = .Cells.Find(kodenama, LookIn:=xlValues)
If Not NAMA Is Nothing Then
kolom = NAMA.Column
KolomKosong = .Cells(NAMA.Row, 1).End(xlToRight).Offset(0, 1).Column
'Or
'KolomKosong = .Cells(NAMA.Row, kolom).End(xlToRight).Offset(0, 1).Column
DPTpicker1.Value = .Cells(KolomKosong).Value
TextBox1.Value = .Cells(KolomKosong + 1).Value
Else
MsgBox kodenama & " value not found in the sheet", vbExclamation
End If
End With
End Sub
Artik
code error '35787'
can't set value to null when checkbox property = false
what's mean for that error message?
Artik
08-18-2019, 08:38 AM
Show the code and mark where the error occurs, because the current code does not mention the CheckBox control.
Artik
hyudien
08-18-2019, 08:46 AM
Private Sub cmdinput_Click()
Dim kodenama As String
Dim NAMA As Range
Dim kolom As Long
Dim KolomKosong As Long
kodenama = Me.ComboBox1.Value
With Worksheets("angsuran")
Set NAMA = .Cells.Find(kodenama, LookIn:=xlValues)
If Not NAMA Is Nothing Then
kolom = NAMA.Column
KolomKosong = .Cells(NAMA.Row, kolom).End(xlToRight).Offset(0, 1).Column
Me.DTPicker1.Value = .Cells(KolomKosong).Value
Me.TextBox1.Value = .Cells(KolomKosong + 2).Value
Else
MsgBox kodenama & " value not found in the sheet", vbExclamation
End If
End With
End Sub
Private Sub CommandButton1_Click()
Unload Me
End Sub
Private Sub TextBox1_Change()
TextBox1 = Format(TextBox1, "Rp#,##0")
End Sub
Private Sub UserForm_Initialize()
Dim c As Range
With Worksheets("angsuran")
For Each c In .Range(.Range("b7"), .Range("b" & .Rows.Count).End(xlUp))
If c.Value <> "" Then ComboBox1.AddItem c.Value
Next c
End With
End Sub
Sub BERSIHKAN()
Dim AdaText
For Each AdaText In Me.Controls
If TypeOf AdaText Is MSForms.TextBox Then
AdaText.Text = ""
End If
Next AdaText
Me.TextBox1.SetFocus
End Sub
This all my code. Always error when i try to sumbit my data. Sorry if i make a mistake, cause me as beginer didn't have a teacher for vba code :crying:
Regards
Artik
08-18-2019, 09:00 AM
Can you indicate the place in the code where the error 35787 occurs?
Artik
hyudien
08-18-2019, 09:12 AM
already resolved.
But when i run it, the value not like in my mind.
I want to place the value like in this pic
24838
hope you can help me for this problem sir
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.