Why does my Userform freeze when ShowModal is False?
I am new to Modal and Modeless Userforms. I am trying to build a simple Userform as a proof of concept that you can change the contents of cells on a sheet and still run your Userform. My goal is to have a Userform that stays loaded, shown, and swaps the values of two cells every time I hit swap cells.
For simplicity’s sake, let’s just assume that no data validation is needed.
This Userform has two RefEdits and a Command Button called cmdSwapCells. When hit, the command button swaps the contents of the two cells referenced by the RefEdits. Here is the code for the sub, SwapCellValues, which is called when the cmdSwapCells_Enter or the cmdSwapCells_Click events trigger.
Private Sub SwapCellValues()
Dim RangeA As Range, RangeB As Range
ValA As String, ValB As String
Set RangeA = Range(RefEdit1.value)
Set RangeB = Range(RefEdit2.value)
ValA = RangeA.value
ValB = RangeB.value
RangeA.value = ValB
RangeB.value = ValA
End Sub
I am new to Modal and Modeless Userforms. I am trying to build a simple Userform as a proof of concept that you can change the contents of cells on a sheet and still run your Userform. My goal is to have a Userform that stays loaded, shown, and swaps the values of two cells every time I hit swap cells. For simplicity’s sake, let’s just assume that no data validation is needed. This Userform has two RefEdits and a Command Button called cmdSwapCells. When hit, the command button swaps the contents of the two cells referenced by the RefEdits. Here is the code for the sub, SwapCellValues, which is called when the cmdSwapCells_Enter or the cmdSwapCells_Click events trigger. Private Sub SwapCellValues()
Dim RangeA As Range, RangeB As Range
ValA As String, ValB As String
Set RangeA = Range(RefEdit1.value)
Set RangeB = Range(RefEdit2.value)
ValA = RangeA.value
ValB = RangeB.value
RangeA.value = ValB
RangeB.value = ValA
End Sub Read More