Consulting

Results 1 to 12 of 12

Thread: Run-time error code "438"

  1. #1
    VBAX Regular
    Joined
    Jul 2019
    Posts
    6
    Location

    Question Run-time error code "438"

    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

  2. #2
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,724
    Location
    "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
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  3. #3
    VBAX Regular
    Joined
    Jul 2019
    Posts
    6
    Location
    Thanks for help me. But when i try to run that code than error change to 1004. So, what's wrong?

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    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
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  5. #5
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,724
    Location
    Quote Originally Posted by hyudien View Post
    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?
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  6. #6
    VBAX Regular
    Joined
    Jul 2019
    Posts
    6
    Location
    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

  7. #7
    VBAX Mentor
    Joined
    Dec 2008
    Posts
    404
    Location
    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

  8. #8
    VBAX Regular
    Joined
    Jul 2019
    Posts
    6
    Location
    Quote Originally Posted by Artik View Post
    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?

  9. #9
    VBAX Mentor
    Joined
    Dec 2008
    Posts
    404
    Location
    Show the code and mark where the error occurs, because the current code does not mention the CheckBox control.


    Artik

  10. #10
    VBAX Regular
    Joined
    Jul 2019
    Posts
    6
    Location
    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

    Regards

  11. #11
    VBAX Mentor
    Joined
    Dec 2008
    Posts
    404
    Location
    Can you indicate the place in the code where the error 35787 occurs?


    Artik

  12. #12
    VBAX Regular
    Joined
    Jul 2019
    Posts
    6
    Location
    already resolved.
    But when i run it, the value not like in my mind.
    I want to place the value like in this pic
    Untitled.jpg
    hope you can help me for this problem sir


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •