[Solved] Latex: How to insert vertical line divider on a certain cells in table?

madschm Asks: Latex: How to insert vertical line divider on a certain cells in table?
I am trying to add a vertical line in the first row between X and Y that is consistent with the placement of the vertical line in the rows below. When I do multicolumn{3}{l|}{textbf{X}} & multicolumn{3}{|l}{textbf{Y}} or multicolumn{3}{|l|}{textbf{X}} & multicolumn{3}{|l|}{textbf{Y}} the contents of the rows disappear. But these seem to be the solutions in other posts. Is there an easy fix?

Code:
documentclass{article}
 usepackage{array,multirow,graphicx}
  usepackage{nicematrix}
  usepackage{lineno}
  usepackage{color, colortbl}
  definecolor{aliceblue}{rgb}{0.94, 0.97, 1.0}
 usepackage{float}
 begin{document}

 begin{table}[!h]
   centering
   begin{NiceTabular}{|c|l|l|l|l|l|l|l|}
     hline
     & & multicolumn{3}{l}{textbf{X}} & multicolumn{3}{l}{textbf{Y}} \ hline
      & textbf{Region} & textbf{r} & textbf{$R^2$} & textbf{p-value}& textbf{r} & textbf{$R^2$} & textbf{p-value} \ hline
      Block{4-1}{rotate{textbf{CLCH}}}
      & Ross Sea& -0.973 & 0.947 & 2.417 e-8  & -0.996 & 0.992 & 8.704 e-13\
      & Amundsen-Bellingshausen Seas & -0.901 & 0.813 & 7.766 e-7& -0.637 & 0.406 & 0.006  \
      & Antarctic Peninsula  & -0.607 & 0.369 & 0.009& -0.059 & 0.004 & 0.821 \
      & Weddell Sea& -0.590 & 0.348 & 0.013 & -0.889 & 0.789 & 1.861 e-6  \
      & East Antarctica & -0.954 & 0.910 & 2.953 e-9 & -0.975 & 0.952 & 2.619 e-11  \ hline hline
      
      Block{5-1}{rotate{textbf{CLCM}}}
      rowcolor{aliceblue}
      & Ross Sea & 0.341 & 0.117 & 0.254 & 0.842 & 0.708 & 0.0003\
      rowcolor{aliceblue}
      & Amundsen-Bellingshausen Seas  & 0.229 & 0.052 & 0.377 & 0.939 & 0.881 & 2.515 e-5 \
      rowcolor{aliceblue}
      & Antarctic Peninsula & 0.719 & 0.517 & 0.001 & -0.824 & 0.679 & 4.734 e-5 \
      rowcolor{aliceblue}
      & Weddell Sea & 0.817 & 0.668 & 6.204 e-5  & 0.708 & 0.501 & 0.001\
      rowcolor{aliceblue}
      & East Antarctica  & -0.372 & 0.138 & 0.141 & -0.414 & 0.172 & 0.098 \ hline
   end{NiceTabular}
 end{table} 

 end{document}


example image

Ten-tools.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, Ten-tools.