In this theoretical study, the Madelung constant (A M ) both for a 2D layer and parent 3D bulk crystal of metal diiodides MI 2 (M=Mg, Ca, Mn, Fe, Cd, Pb) with CdI 2 (2 H polytype) structure is calculated on the basis of the lattice summation method proposed in author's earlier work. This method enabled, both for a 2D layer and 3D bulk crystal of these compounds, to obtain an analytic dependence of the Madelung constant, A M (a, c, u), on the main crystallographic parameters a, c, and u. The dependence A M (a, c, u) reproduces with a high accuracy the value of the constant A M not only for metal diiodides MI 2 with CdI 2 (2 H polytype) structure, but also for metal dihalides (MX 2 ) and metal dihydroxides [M(OH) 2 ] with the same structure. With the use of the high-pressure experimental results available in literature particularly for FeI 2 , it is demonstrated that the above analytic dependence A M (a, c, u) is also valid for direct and precise analysis of the pressure-dependent variation of the Madelung constant.