Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

Warning message while merging cells in excel through excel buffer in navision?

(1) ShareShare
ReportReport
Posted on by

Hi all,

I have included the following codes for merge of cells in excel , in excel buffer in navision.

XlWrkSht := XlApp.ActiveSheet;

XlWrkSht.Range(FromRec.xlColID + FromRec.xlRowID + ':' + ToRec.xlColID + ToRec.xlRowID).Select;
XlWrkSht.Range(FromRec.xlColID + FromRec.xlRowID).HorizontalAlignment := -4108;

XlWrkSht.Range(FromRec.xlColID + FromRec.xlRowID + ':' + ToRec.xlColID + ToRec.xlRowID).cells.Merge;

The code is working properly. but it keeps on popping warning message.

"The selection contains multiple data values. Uniting in a single cell will be retained only the data in the upper left."

 

I tried to find out the issue,but cannot understand,

Could any one help, how to proceed.

*This post is locked for comments

  • Nilam Bhor Profile Picture
    153 on at
    Warning message while merging cells in excel through excel buffer in navision?
    Hi ,
    In above code what is data type XlWrkSht?
     
  • Community Member Profile Picture
    on at
    RE: Warning message while merging cells in excel through excel buffer in navision?

    Thank you all very much, for your kind support and guidance.

    The Problem in my case is that I have inserted a Empty value ('') next to the cell , That i was trying to merge.

    for example

    Please refer Fig1.

    Solution, as suggested by all of you, I have removed the empty value which i was trying to merge along with cell valve.

    Now it is working fine.

    Thank you experts for giving your valuable time and suggestion .

    sample-test.PNG

  • Verified answer
    Binesh Profile Picture
    7,885 on at
    RE: Warning message while merging cells in excel through excel buffer in navision?

    Hello Vijay,

    follow the saurav solution, Why because it's an excel warning, you can check in MS excel also.

  • Verified answer
    Community Member Profile Picture
    on at
    RE: Warning message while merging cells in excel through excel buffer in navision?

    Hi Vijay,

    If you merge the four cells (Column A to Column D) as mentioned in the screen shot, you would definitely get such error.

    You can not merge the multiple cells having values in all the columns, otherwise system would retain only Upper Left column value.

    You can try to merge the cell in Excel directly and you would find similar issue in excel as well.

    If you want to merge the cells, only one cell should have value, otherwise you would get such error.

    Hope this helps.

  • Verified answer
    Alexander Ermakov Profile Picture
    28,094 on at
    RE: Warning message while merging cells in excel through excel buffer in navision?

    This message is not because of your coding, but due to the Excel behavior itself. Trying to merge two or more cells in Excel itself will produce you a warning message. You can first clean the cells (perhaps, reading and storing the values in some variable), merge them, and only then put the values there into a merged cell.

  • Verified answer
    Saurav.Dhyani Profile Picture
    14,312 Super User 2025 Season 1 on at
    RE: Warning message while merging cells in excel through excel buffer in navision?

    Your Coding is correct, the error message is not due to the coding its due to the excel. Even if you try this in excel the same error message will popup.

    The way you are approaching the solution need to be changed -

    1. While writing content in excel buffer table concatenate the string that you want to place in A2,B2,C2&D2 and put that value in A2.

    2. So your string in A2 will be "Sample Entry For Test".

    3. Now use merge cell function to merge A2,B2,C2 and D2 to expand the size of column A2.

    Hope it make sense.

  • Verified answer
    Community Member Profile Picture
    on at
    RE: Warning message while merging cells in excel through excel buffer in navision?

    I have tried already , withwhat ever suggestion you gave.

    Still Im getting the same warning message.

    I dont understand it.

    Any Suggestion .Further 

  • Verified answer
    Saurav.Dhyani Profile Picture
    14,312 Super User 2025 Season 1 on at
    RE: Warning message while merging cells in excel through excel buffer in navision?

    For NAV 2009 Refer here -

    saurav-nav.blogspot.in/.../navision-export-to-excel-with-merge.html

  • Verified answer
    Community Member Profile Picture
    on at
    RE: Warning message while merging cells in excel through excel buffer in navision?

    Thank you Suresh and Binesh for your valuble input.

    I understood the solution and i have applied the same in my coding too.

    But i would make it more clear for both of you ...That why the problem occurs.

    I insert the value first and the i tried to apply merge the cells in excel.

    Please refer Fig 1

    When trying to merge the cells , which is already having value .. i am getting this warning mesaage.

    When trying to merge cells of excel through excel buffer table. we know that we can call merge only after "RecExcel.CreateSheet".

    Thats is where i think warning occurs.

    Is there is any better way to handle it.

    fig1.PNG

  • Verified answer
    Binesh Profile Picture
    7,885 on at
    RE: Warning message while merging cells in excel through excel buffer in navision?

    Hello vijay,

    write a function in excelbuffer table,

    See the bellow screenshot. it works fine.

    2016_2D00_07_2D00_04_5F00_19_2D00_42_2D00_05.png

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 293,296 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,093 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans