Should I set the Enabled property of OLEObject or OLEObject.Object?
<p>I'm working on a Excel VBA project. In Sheet1 I have a table with 3 command buttons for each row. Outside this table I have another command button named "cbSwap". When I click to this button, it opens a user form. This user form have 2 text boxes and a button. The user form takes two values from two text boxes and transmits them to a function named SwapTwoRange. This function takes the values, uses them as Excel range names. Here's the function:</p>

<pre><code>Function SwapTwoRange(val1 As String, val2 As String)
  Dim arr1 As Variant, arr2 As Variant
  Dim Rng1 As Range, Rng2 As Range

  Set Rng1 = ThisWorkbook.Sheets("Sheet1").Range("row" &amp; val1)
  Set Rng2 = ThisWorkbook.Sheets("Sheet1").Range("row" &amp; val2)

  Application.ScreenUpdating = False
  arr1 = Rng1.Value
  arr2 = Rng2.Value
  Rng1.Value = arr2
  Rng2.Value = arr1
  Application.ScreenUpdating = True

  'No problem occured until here.

  If (WorksheetFunction.CountA(Rng1) = 0) Then
      ThisWorkbook.Sheets("Sheet1").OLEObjects("cbStartRow" &amp; val1).Object.Enabled = True
      ThisWorkbook.Sheets("Sheet1").OLEObjects("cbEndRow" &amp; val1).Object.Enabled = False
      ThisWorkbook.Sheets("Sheet1").OLEObjects("cbClearRow" &amp; val1).Object.Enabled = False
  Else
      ThisWorkbook.Sheets("Sheet1").OLEObjects("cbStartRow" &amp; val1).Object.Enabled = False
      ThisWorkbook.Sheets("Sheet1").OLEObjects("cbEndRow" &amp; val1).Object.Enabled = True
      ThisWorkbook.Sheets("Sheet1").OLEObjects("cbClearRow" &amp; val1).Object.Enabled = True
  End If

  If (WorksheetFunction.CountA(Rng2) = 0) Then
    ThisWorkbook.Sheets("Sheet1").OLEObjects("cbStartRow" &amp; val2).Object.Enabled = True
      ThisWorkbook.Sheets("Sheet1").OLEObjects("cbEndRow" &amp; val2).Object.Enabled = False
      ThisWorkbook.Sheets("Sheet1").OLEObjects("cbClearRow" &amp; val2).Object.Enabled = False
  Else
      ThisWorkbook.Sheets("Sheet1").OLEObjects("cbStartRow" &amp; val2).Object.Enabled = False
      ThisWorkbook.Sheets("Sheet1").OLEObjects("cbEndRow" &amp; val2).Object.Enabled = True
      ThisWorkbook.Sheets("Sheet1").OLEObjects("cbClearRow" &amp; val2).Object.Enabled = True
  End If
End Function
</code></pre>

<p><em>cbStartRow</em>, <em>cbEndRow</em> and <em>cbClearRow</em> are the command buttons in the table rows in Sheet1. When if block executes, they seem as they are enabled/disabled as I want. But when I select (for example) a <strong>disabled</strong> command button, and look at its properties, its <strong>Enabled</strong> property is <strong>True</strong>. And the program doesn't work as I want. I must refer to command buttons names with the values entered to text boxes (for example if textbox1's value is "1" , the first if-else block will change cbStartRow1, cbEndRow1 and cbClearRow1's Enabled property.)</p>

<p>How can I do it without this problem? I have been searching for a solution in internet forums for last 8 days, but I couldn't find a correct solution. Please help. Thanks anyway.</p>