{"id":11415,"date":"2021-12-08T03:39:46","date_gmt":"2021-12-08T03:39:46","guid":{"rendered":"https:\/\/lgildv5i97.onrocket.site\/answers\/?post_type=question&#038;p=11415"},"modified":"2021-12-08T03:40:02","modified_gmt":"2021-12-08T03:40:02","slug":"solved-help-to-center-an-object-in-a-specific-cell-using-excel-vba","status":"publish","type":"question","link":"https:\/\/computing.net\/answers\/office\/help-to-center-an-object-in-a-specific-cell-using-excel-vba\/20891.html","title":{"rendered":"Solved Help To Center An Object In a Specific Cell Using Excel VBA"},"content":{"rendered":"<p>I need help to modify the below code to horizontally center the object (down arrow) in the specified cell (\u201cC3\u201d), so it is centered in column C, rather than left aligned.<br \/>\nI think there may be a way to do this by using an offset to the next column and then dividing by 2, to result in a centered position, but am not sure how to do so. I also need to add this same object to the adjacent cell, (\u201cD3\u201d), which will also need to be horizontally centered within column D. Any help would be much appreciated!<\/p>\n<p>The below code inserts the object that I want and positions it within the correct cell, but has it left aligned, vs centered in that column. The width of all columns in the worksheet may change, so I can\u2019t specify a fixed point position.<\/p>\n<p>&nbsp;<\/p>\n<pre>Sub AddDownArrow()\r\n\r\nDim CelLeft As Double\r\nDim CelTop As Double\r\nDim shp As Shape\r\nDim Cel As Range\r\n\r\nSet Cel = Range(\"C3\")\r\nCelLeft = Cel.Left\r\nCelTop = Cel.Top\r\n\r\nSet shp = ActiveSheet.Shapes.AddShape(msoShapeDownArrow, CelLeft, CelTop, 38.16, 77.04)\r\n\r\nEnd Sub<\/pre>\n<p>&nbsp;<\/p>\n<p align=\"right\"><span style=\"font-size: xx-small;\"><i>message edited by User444<\/i><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"inline_featured_image":false,"iawp_total_views":31},"question-category":[53],"question_tags":[],"class_list":["post-11415","question","type-question","status-publish","hentry","question-category-office"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question\/11415","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question"}],"about":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/types\/question"}],"author":[{"embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/comments?post=11415"}],"wp:attachment":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/media?parent=11415"}],"wp:term":[{"taxonomy":"question-category","embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question-category?post=11415"},{"taxonomy":"question_tags","embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question_tags?post=11415"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}