Userform ate problem

Damo10

Active Member
Joined
Dec 13, 2010
Messages
460
Hi,

I have a userform where the operator is to select a choice from the Tankcbo and then there is a change event macro which is to update the Total, I am having a problem if the operator changed the selection where the total does not get updated, during tests it seems to be lagging one selection behind. I put a message box in to check the contents of the Total is empty which it is and then when I press ok the new total appears correctly, but when I take out the message box it goes back to displaying the previous result, any suggestions?

Regards,

Rich (BB code):
Private Sub Tankcbo_Change()
Dim c As Range
Dim d As Long
Dim x As Range
Dim wbk As Workbook
Dim wsfrom As Worksheet
Set wbk = ThisWorkbook
Set wsfrom = wbk.Sheets("Data")
With Application
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With
Me.Total = ""
With wsfrom
Set rng = .Range(.Range("II7"), .Range("II" & .Rows.count).End(xlUp))
For Each c In rng
If c.Value = Me.McNo.Text And c.Offset(, 1) = Me.WON.Text And c.Offset(, 12).Text = Me.FlavNo.Text Then
d = c.Row
Me.Total = ""
With wsfrom
.Cells(d, 260).Value = ""
.Cells(d, 260).Value = Me.Tankcbo.Text
End With
Me.Total = ""
MsgBox Me.Total.Value
With Application
.Calculation = xlCalculationAutomatic
.ScreenUpdating = True
End With
With wsfrom
If c.Offset(, 7).Text = "Natural" Then
Me.Total = Format(c.Offset(, 27).Value, "0")
Else
Me.Total = c.Offset(, 27).Value
End If
End With
End If
Next c
Me.Row = d
Me.TankNo.SetFocus
End With
With Application
.Calculation = xlCalculationAutomatic
.ScreenUpdating = True
End With
End Sub
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop

Forum statistics

Threads
1,224,521
Messages
6,179,277
Members
452,902
Latest member
Knuddeluff

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top