0

I have to copy values from one worksheet, to another and I cant write the code without error 438. This is the Orignal Sheet and I have to create a script which copies each column, to the last row, and pastes it into other sheet as one column, example.

The code:

Sub CopyPaste()
    Dim origws As Worksheet
    Dim destws As Worksheet
    
    Dim i As Long    'Column counter
    Dim j As Long    'Row Counter
    Dim k As Long    'Counter in NewSheet
    
    Set origws = Sheets("31 - 61 kolona")
    Set destws = Sheets("Slaganje")
    
    k = 1
    Worksheets("31 - 61 kolona").Activate  'Activateing original WorkSheet
    'Looping through the sheet 
    For i = 1 To 1000
        For j = 1 To 1000
            If IsEmpty(Cells(j, i)) Then   'If there is an blank cell, move to next column
                Exit For
            End If
            
            Cells(j, i).Copy                'copy value from cell
            Worksheets("Slaganje").Activate 'Activate destination sheet
            Cells(k, 1).Paste               'paste the copied cell in the destination sheet
            k = k + 1                       'move counter to next row
            
            Worksheets("31 - 61 kolona").Activate  'activate original sheet
        Next j   'move to next row
    Next i   'move to next column
End Sub

This is my attempt, hope you can help me.

GSerg
  • 73,524
  • 17
  • 153
  • 317
peraDlazy
  • 1
  • 1
  • If you step through with F8, which line produces the error? Also, you might want to read ["How to Avoid Using Select in Excel VBA"](https://stackoverflow.com/questions/10714251/how-to-avoid-using-select-in-excel-vba) (For other people's reference: Error Code 438 is "object doesn't support this property or method") – Chronocidal Jul 12 '21 at 11:43

0 Answers0