+ Reply to Thread
Results 1 to 2 of 2

showing error at Selection.Delete Shift:=xlToLeft

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    04-06-2013
    Location
    india
    MS-Off Ver
    Excel 2007
    Posts
    193

    showing error at Selection.Delete Shift:=xlToLeft

    Sub original1()
    Dim k As Integer
    Dim i As Integer
    For k = 3 To 20
    If Range("Q" & k).Value <> "" Then
    
    MsgBox ActiveCell.Row
    
    ActiveCell.Offset(1, 0).EntireRow.Insert
    With ActiveCell
    For i = 1 To 10
        .Resize(1, 4).Copy Destination:=Worksheets("Master File").Range("M" & .Row + 1)
        .Resize(1, 4).Select
        '.Resize(1, 4).Value = ""
        'ActiveCell.Value = ""
        '.Resize(1, 4).Delete Shift:=xlToLeft
        Selection.Copy
        Selection.Delete shift:=xlToLeft
        If .Value = "" Then
        End If
    Next i
    i = i + 1
    End With
    Else
    Exit Sub
    End If
    Next k
    k = k + 1

    error shows object required
    any one help?
    Last edited by anilg0001; 06-15-2013 at 07:55 AM.

  2. #2
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: showing error at Selection.Delete Shift:=xlToLeft

    Hi, anilg0001,

    if you want to get into serious programming get away from both using ActiveCell as well as doing unnecessary Selects.

    What do you want to get from the second loop with the variable i as it is not used in your code?

    Sub original1()
    Dim k As Integer
    Dim i As Integer
    For k = 3 To 20
      With Cells(k, "Q")
        If .Value <> "" Then
          .Offset(1, 0).EntireRow.Insert
          For i = 1 To 10
              .Resize(1, 4).Copy Destination:=Worksheets("Master File").Range("M" & .Row + 1)
      '        .Resize(1, 4).Select
              '.Resize(1, 4).Value = ""
              'ActiveCell.Value = ""
              '.Resize(1, 4).Delete Shift:=xlToLeft
      '        Selection.Copy
              .Resize(1, 4).Delete shift:=xlToLeft
    '          If .Value = "" Then
    '          End If
          Next i
        Else
          Exit Sub
        End If
      End With
    Next k
    End Sub
    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

+ 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