2017-12-29 1 views
0

는 현재 내가 엑셀의 테이블에 값을 추가하는 양식을 사용하고 있습니다 :VBA를 사용하여 버튼이있는 행을 Excel 테이블에 추가하려면 어떻게합니까?

Private Sub btnSave_Click() 
    Dim lo As Excel.ListObject 
    Dim newRow As Excel.ListRow 
    Dim sheetName As String, tableName As String 
    sheetName = "Dados" 
    tableName = "articles" 
    Set lo = getTable(sheetName, tableName) 

    Dim ref As Integer 
    ref = getMaxRef(tableName) 

    Dim btnEdit As Button, btnDelete As Button 
    'How can I add this 2 buttons to the newRow? 

    Set newRow = lo.ListRows.Add(AlwaysInsert:=True) 
    newRow.Range = Array(ref, cboStores.Value, cboTypes.Value, cboMaterials.Value, txtDescription.Value, txtWeight.Value, txtPrice.Value) 

    Unload Me 
End Sub 

는 것이 가능 newRow에서 직접 버튼을 추가하거나 행을 추가 한 후 내가 세포를 검색해야 하는가하는 것입니다 그런 다음 버튼을 추가 하시겠습니까?

답변

0

다음은 일반적인 코드입니다. 버튼의 크기를 A1 셀의 크기로 맞 춥니 다.

Sub Test() 
    Dim btn As Button 
    With Range("A1") 
     Set btn = Sheet1.Buttons.Add(.Left, .Top, .Width, .Height) 
    End With 
End Sub 
관련 문제