Share via

VBA CODING FOR MERGED CELLS

Anonymous
2013-01-17T19:29:33+00:00

is it possible to copy the value of a single cell in a sheet to a merged cell in another sheet?

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Anonymous
2013-01-17T20:29:23+00:00

thanks for your speedy reply. my problem is that i want to transfer the value in b6 in sheet 1 to a range a1:j1 in sheet 2. when i try the code msg is "run time error 1004 cannot change part of a merged cell."

Using what I posted originally as a model, each of the following formulas work for me (the bold D1 shown in the second formula could be any one of the cells in the range A1:J1 on Sheet2)...

Sheets("Sheet2").Range("A1").Value = Sheets("Sheet1").Range("B6").Value

Sheets("Sheet2").Range("D1").MergeArea.Value = Sheets("Sheet1").Range("B6").Value

Sheets("Sheet2").Range("A1:J1").Value = Sheets("Sheet1").Range("B6").Value

Do these work for you? If not, do you have Sheet2 protected?

Was this answer helpful?

2 people found this answer helpful.
0 comments No comments

4 additional answers

Sort by: Most helpful
  1. Anonymous
    2013-01-17T20:20:02+00:00

    when i try vba code i get the message: "run time error 1004 cannot change part of a merged cell."

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2013-01-17T20:19:22+00:00

    thanks for your speedy reply. my problem is that i want to transfer the value in b6 in sheet 1 to a range a1:j1 in sheet 2. when i try the code msg is "run time error 1004 cannot change part of a merged cell."

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2013-01-17T19:57:53+00:00

    is it possible to copy the value of a single cell in a sheet to a merged cell in another sheet?

    If you mean you want to be able to specify any cell within the merged cells, you could do it this way... assume the merged cells are Sheet2!D4:F6 and you wanted to be able to specify any one of those cells in order for the value in, say, Sheet1!A1 to be copied into the merged cells, you could use this code line... let's say you wanted to specify E5, then

    Sheets("Sheet2").Range("E5").MergeArea.Value = Sheets("Sheet1").Range("A1").Value

    If you know the address for the top left cell of the merged cells, you can do a direct assignment like this...

    Sheets("Sheet2").Range("D4").Value = Sheets("Sheet1").Range("A1").Value

    If this is not what you meant, can you please expand your description so we can figure out what you actually want (before and after examples are always good to provide).

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2013-01-17T19:49:29+00:00

    What happens when you try?

    Gord

    Was this answer helpful?

    0 comments No comments