Results 1 to 2 of 2

Thread: [RESOLVED] [Excel 2k3 + VBA] Runtime error '1004' Cannot change part of a merged cell

  1. #1

    Thread Starter
    Member
    Join Date
    Nov 2009
    Location
    NB, Canada
    Posts
    52

    Resolved [RESOLVED] [Excel 2k3 + VBA] Runtime error '1004' Cannot change part of a merged cell

    Hi,

    each time I try to apply template format with data from access I receive this message: Runtime error '1004' Cannot change part of a merged cell

    and it points to this line:
    Code:
    ActiveSheet.Range(Cells(x, y), Cells(x + Int(c / 50), y + 6)).Clear
    and this is the complete section of the code:

    Code:
    '*********************************************************************
    '* INPUT top left cell of the merge
    '* INPUT "[ROWS]#[COLUMNS]" offset to be merged (void = 0)
    '*********************************************************************
    Public Sub str_merge(row, col, instructions)
    Dim x, y As Integer
    Dim q As Variant
    q = Split(instructions, "#")
    y = q(UBound(q))
    If Not q(0) = "" Then x = q(0)
    ActiveSheet.Range(Cells(row, col), Cells(row + x, col + y)).MergeCells = True
    End Sub
    Public Function memo_merge(x, y, c)
    ActiveSheet.Range(Cells(x, y), Cells(x + Int(c / 50), y + 6)).Clear
    ActiveSheet.Range(Cells(x, y), Cells(x + Int(c / 50), y + 6)).Interior.color = RGB(255, 255, 255)
    ActiveSheet.Range(Cells(x, y), Cells(x + Int(c / 50), y + 6)).Borders.LineStyle = True
    ActiveSheet.Range(Cells(x, y), Cells(x + Int(c / 50), y + 6)).MergeCells = True
    memo_merge = x + Int(c / 50)
    End Function
    How to fix it, please?
    Best Regards

  2. #2

    Thread Starter
    Member
    Join Date
    Nov 2009
    Location
    NB, Canada
    Posts
    52

    Re: [Excel 2k3 + VBA] Runtime error '1004' Cannot change part of a merged cell

    fixed by changing:

    Code:
    ActiveSheet.Range(Cells(x, y), Cells(x + Int(c / 50), y + 6)).Clear
    to

    Code:
     
    ActiveSheet.Range(Cells(x, y), Cells(x + Int(c / 50), y + 6)).Value=""


    Edited byAdmin-Deva few seconds agorefine
    Marked As Answer byAdmin-Deva few seconds ago

Posting Permissions

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



Click Here to Expand Forum to Full Width