Re: Selecting cells and merging, with VBA

  • Hi, I'm relatively new to using VBA and am having a similar problem. I want to select a range of cells and merge it but I am getting the Runtime error 1004 as well. here's my code:

    Code
    Dim LastRow As Long, x As Integer, y As Integer
        
    mtSH.Select
    LastRow = Range("AF" & Rows.Count).End(xlUp).Row
        x = LastRow + 2
    Range("P" & x).Offset(0, 2).Select
    y = ActiveCell.Row
    Range("S" & y).Select
    Range(ActiveCell.Offset(0, 0), ActiveCell.Offset(0, 5)).Merge
    ActiveCell.Select
  • Re: Selecting cells and merging, with VBA


    Assuming mtSh is a worksheet, try...

    Code
    Dim x As Long
        With Worksheets("mtSH")
            x = .Range("AF" & .Rows.Count).End(xlUp).Row + 2
            With .Range("S" & x, "S" & x + 5)
                .Merge
                .Select
            End With
        End With

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!