+ Reply to Thread
Results 1 to 6 of 6

Run-time Error 438

Hybrid View

  1. #1
    Registered User
    Join Date
    10-09-2012
    Location
    Pennsylvania
    MS-Off Ver
    Excel 2020
    Posts
    45

    Run-time Error 438

    Hi everyone,

    I'm very new to VBA and have gotten this code to work for another sheet and am basically just tweaking it for my new requirements. Wondering if anyone could help explain why I'm receiving a 438 error of "Object doesn't support this property or method". Below is my code. Thanks!

    Sub CopyPasteEnrollReqID()
    Dim lrow As Long, i As Long, lastrow As Long, x As Long, counter As Long
    
    With Worksheets("Requirements")
        lrow = .Range("A" & .Rows.Count).End(xlUp).Row
        For i = 2 To lrow
                If .Cells(i).Value Like "Enrollment Through Delinquency" Then
                .Range("A" & i & ":A" & i).Copy Worksheets("Enroll").Range("J" & Rows.Count).End(xlUp).Offset(1, 0)
                lastrow = Worksheets("Enroll").Range("J" & Rows.Count).End(xlUp).Row
                Worksheets("Enroll").Cells(lastrow).Value = .Cells(i)
                End If
        Next i
        Worksheets("Enroll").Columns("A:A").HorizontalAlignmnet = xlCenter
    End With
    
    End Sub

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646
    Which line of code causes the error?
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    10-09-2012
    Location
    Pennsylvania
    MS-Off Ver
    Excel 2020
    Posts
    45

    Re: Run-time Error 438

    Sorry, wish I could say, but every time I try to Debug and "Step Into", it throws up that error. Let me know if you have any other ideas how to see which line is the issue. Thanks!

  4. #4
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Run-time Error 438

    Not quite sure. It should be telling you in Visual Basic Editor which line is causing the problem. A couple things I noticed

    Range("A" & i & ":A" & i)
    Is just a single cell

    Worksheets("Enroll").Cells(lastrow).Value = .Cells(i)
    I have a feeling this isn't going to do what you want it to do

    Let us know which line of code it error on.

  5. #5
    Registered User
    Join Date
    10-09-2012
    Location
    Pennsylvania
    MS-Off Ver
    Excel 2020
    Posts
    45

    Re: Run-time Error 438

    So the code originally worked, however, it copied a few extra things that I didn't want, so I tried to tweak it. Below is the code that previously "worked". Basically, I took the code from another sheet that it worked perfectly on and tried to transform it to work for this scenario (and I don't know quite enough to fully do that properly - as you can tell).

    Sub CopyPasteEnrollReqID()
    Dim lrow As Long, i As Long, j As Long, lastrow As Long, x As Long, counter As Long
    
    With Worksheets("Requirements")
        lrow = .Range("A" & .Rows.Count).End(xlUp).Row
        For i = 2 To lrow
            For j = 15 To 15
                If .Cells(i, j).Value Like "Enrollment Through Delinquency" Then
                .Range("A" & i & ":A" & i).Copy Worksheets("Enroll").Range("J" & Rows.Count).End(xlUp).Offset(1, 0)
                lastrow = Worksheets("Enroll").Range("J" & Rows.Count).End(xlUp).Row
                Worksheets("Enroll").Cells(lastrow, j).Value = .Cells(i, j)
                End If
            Next j
        Next i
        Worksheets("Enroll").Columns("A:A").HorizontalAlignmnet = xlCenter
    End With
    
    End Sub
    I appreciate any help, but I may just re-post in the VBA forum and see if someone can help me from scratch! Thanks again!
    Last edited by ccowman; 01-16-2013 at 02:30 PM.

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: Run-time Error 438

    I can't see anything wrong with the code and I can't test it - no worksheet/workbook/data for that.

    Can you not tell us which line of code the error happens on?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1