How can I adress merged cells in excel sheet?

33 views (last 30 days)
For example: cells A1:D1 are merged und contain the string 'test'. How can I correctly adress these cells to get the string?
I tried by adressing the first cell of merged cells but read out the first letter only.

Accepted Answer

Kiran Felix Robert
Kiran Felix Robert on 8 Oct 2020
Hi Denny,
You can use the readcell function to readout the cell.
The following is an example, assuming you have merged cells A1 to D1 you can specify the range as,
M = readcell('Book1.xlsx','Range','A1:D1');
This will readout 4 cells with M(1) containing the required text
Or
M = readcell('Book1.xlsx','Range','A1:A1');
This will readout the merged cells with M containing the required text
Kiran Felix Robert
  1 Comment
Sergio Silva
Sergio Silva on 24 Oct 2022
What if I'd like to have each merged cell filled with the same content (for example, I want M to be equal to {'text' 'text' 'text' 'text'})?
Thanks!

Sign in to comment.

More Answers (0)

Tags

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!