vba code doesn't work from computer to computer

CQuirin

New Member
Joined
Jul 31, 2007
Messages
1
Hi,
I have a workbook that has 5 worksheets. Each sheet represents the days of the week. The problem is the code works in my workbook but not on others. It only populates the project name not the project number. The result wanted is for the user to select from the project name form the list on charge nums sheet and populate the project number at the same time for each day of the week. Excel fills in project name and project number in two different columns. The cells are lock to keep the user from entering data. The versions of excel are the same. Help if you can. Thanks

Each has the following code:
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Dim wsChargeNums As Worksheet
Dim ProjectListRow As Long
Dim ProjectNoRow As Long

On Error GoTo errHandler
Set wsChargeNums = Worksheets("Charge Nums")

If Target.Count > 1 Then Exit Sub
Application.EnableEvents = False

Select Case Target.Column
Case 2
With Target
If .Value = "" Then
.Offset(0, 1).Value = ""
Else
ProjectListRow = Application.Match(.Value, wsChargeNums.Range("ProjectList"), 0)
.Offset(0, 1).Value = wsChargeNums.Range("ProjectNo")(ProjectNoRow).Value
End If
End With
Case 3
With Target
If .Value = "" Then
.Offset(0, -1).Value = ""
Else
ProjectListRow = Application.Match(.Value, wsChargeNums.Range("ProjectList"), 0)
.Offset(0, -1).Value = wsChargeNums.Range("ProjectNo")(ProjectListRow).Value
End If
End With
Case Else
'do nothing
End Select

exitHandler:
Application.EnableEvents = True
Exit Sub
errHandler:
MsgBox Err.Number & ": " & Err.Description
GoTo exitHandler

End Sub
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.

brian.wethington

Well-known Member
Joined
Jul 20, 2006
Messages
1,739
Is it just different workbooks or different computers that is the issue. You may need to check the references if it is different machines. To do this go into the VBE and select the tools menu choosing references. Compare this to your references and make sure all this is checked in your references is checked in theirs.
 

Datsmart

Well-known Member
Joined
Jun 19, 2003
Messages
7,985
Looks like your code uses several Named Ranges, do those exist on the other PC's?
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,167,956
Messages
5,856,507
Members
431,819
Latest member
hellosunshine

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
Top