Quantcast
Channel: Active questions tagged excel - Stack Overflow
Viewing all articles
Browse latest Browse all 88868

How to position a button within a cell?

$
0
0

I am having a problem positioning a button within cell.

Clicking the button runs this subroutine:

Public Sub TableDisplayButton()
    Dim cr As Range, cr2 As Range
    With ActiveSheet.Shapes(Application.Caller)
        Set cr = .TopLeftCell
        Set cr2 = .BottomRightCell
        MsgBox cr.Address & ""& cr.Left
        .Left = cr.Left
        .Top = cr.Top
        .Width = Range(cr, cr2).Width
        .Height = Range(cr, cr2).Height
    end with
end sub

The button is slightly shifted left to neighbouring left cell and upon clicking it again it will reposition to another cell.

cr.address displays the correct cell.

Is it possible that .left and .top rounds decimal places to integer value?


Viewing all articles
Browse latest Browse all 88868