ipbr21054
Well-known Member
- Joined
- Nov 16, 2010
- Messages
- 5,726
- Office Version
- 2007
- Platform
- Windows
Morning,
Please could you check my code & advise a fix.
I open my workbook.
It defaults to INCOME (1) to open first.
I see the msgbox asking me to select MONTH & YEAR
I choose to select CLOSE FORM
The form quickly coses then reopens.
I choose to select CLOSE FORM again & it closes.
Now i can do this a few times & this doesnt happen again.
Should i close workbook & reopen the cycle seems to start again
The codes in use is supplied below.
Please could you check my code & advise a fix.
I open my workbook.
It defaults to INCOME (1) to open first.
I see the msgbox asking me to select MONTH & YEAR
I choose to select CLOSE FORM
The form quickly coses then reopens.
I choose to select CLOSE FORM again & it closes.
Now i can do this a few times & this doesnt happen again.
Should i close workbook & reopen the cycle seems to start again
The codes in use is supplied below.
Code:
Private Sub Worksheet_Activate()
If Range("B1") = "" Then
Range("A4").Select
MYFINCOMEONE.Show
Else
End If
End Sub
Code:
Private Sub TransferButton_Click()
Dim i As Integer
Dim ControlsArr As Variant, ctrl As Variant
Dim x As Long
For i = 1 To 2
With Me.Controls("ComboBox" & i)
If .ListIndex = -1 Then
MsgBox "MUST SELECT BOTH OPTIONS", 48, "MONTH & YEAR TRANSFER MESSAGE"
.SetFocus
Exit Sub
End If
End With
Next i
ControlsArr = Array(Me.ComboBox1, Me.ComboBox2)
With ThisWorkbook.Worksheets("INCOME (1)")
For i = 0 To UBound(ControlsArr)
Select Case i
Case 1, 2, 4
.Cells(1, i + 2) = IIf(IsNumeric(ControlsArr(i)), Val(ControlsArr(i)), ControlsArr(i))
Case Else
.Cells(1, i + 2) = ControlsArr(i)
ControlsArr(i).Text = ""
End Select
Next i
End With
ActiveWorkbook.Save
Application.ScreenUpdating = True
MsgBox "Month & Year Have Been Updated", vbInformation, "SUCCESSFUL MESSAGE INCOME 1"
Unload MYFINCOMEONE
End Sub