Hi Diane,
I hope you have the problem fixed. If not, you might want to try the following modified version of the code that causes your problem on the offending computer. It uses 'Conditional Compilation' in an attempt to isolate the problem if it is in fact my Macro that causes the problem.
Instructions are inside the Macro. The aim is to start with everything disabled, and run the Macro. One by One by setting values to 'True', small parts of the code are enabled one by one. The Macro won't do it's intended function, but the aim is not to run the Macro, but to attempt to isolate the 400 error.
Lewis
Option Explicit
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'The following item defines where the 'Sentinel Cell' is to go.
'When the cell is BLANK, then division is allowed.
'After division is performed, the Macro puts a value in the cell that prevents future division.
'
'You can make this cell hidden by using custom format of three semi-colons (;;;)
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
#Const IMPLEMENT_SECTION_A = False
#If IMPLEMENT_SECTION_A = True Then
Const sSheetName = "TestData"
Const sDivisionAllowedSentinel_CELL = "A24"
#End If
Sub DivideContentsOfEntireNamedRangeByTenOnlyOnceConditionallyCompiled()
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'This divides the Entire Contents of range 'TempData' by 10
'The sentinel cell defined in the beginning allows division to occur only once
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'The '#If' statements are called 'CONDITIONAL COMPILATION'. When all the values are
''False' then the routine is a blank shell and does nothing (none of the code is compiled).
'
'The code is standard VBA code and should not cause your 400 error. This is an attempt to
'isolate the problem if it is causesd by something in my code.
'
'If you run the code as is, it is an empty shell and does nothing. If the 400 problem occurs,
'them the 400 problem should occur with any other macro also.
'
'By setting the values to 'True' one by one starting at 'IMPLEMENT_SECTION_A', we are attempting
'to isolate the problem to one section of code.
#Const IMPLEMENT_SECTION_B = False
#If IMPLEMENT_SECTION_B = True Then
Dim r As Variant 'r is each cell in the range
Dim myRange As Range
Dim sSentinelValue As String
MsgBox "Conditional Compilation Version"
#End If
#Const IMPLEMENT_SECTION_C = False
#If IMPLEMENT_SECTION_C = True Then
'All the calculations are to be done on the "TestData" Sheet
Sheets("TestData").Select
#End If
#Const IMPLEMENT_SECTION_D = False
#If IMPLEMENT_SECTION_D = True Then
'Get the value from the Sentinel Cell (Blank means Ok to divide/ anything else means DO NOT DIVIDE)
sSentinelValue = Trim(Range(sDivisionAllowedSentinel_CELL).Text)
If Len(sSentinelValue) > 0 Then
MsgBox "TERMINATING. Division Not Allowed." & vbCrLf & _
"Division already occurred according to the value in Cell '" & sDivisionAllowedSentinel_CELL & "'."
Exit Sub
End If
#End If
#Const IMPLEMENT_SECTION_E = False
#If IMPLEMENT_SECTION_E = True Then
'Assign the range object
Set myRange = Range("TempData")
#End If
#Const IMPLEMENT_SECTION_F = False
#If IMPLEMENT_SECTION_F = True Then
'Loop thru the range
'Divide all non-zero values by 10
For Each r In myRange
'Debug.Print r.Address(False, False)
If r.Value <> 0 Then
r.Value = r.Value / 10#
End If
Next r
#End If
#Const IMPLEMENT_SECTION_G = False
#If IMPLEMENT_SECTION_G = True Then
'Set the Sentinel Cell
Range(sDivisionAllowedSentinel_CELL).Value = "Divided by 10 on " & Now()
#End If
#Const IMPLEMENT_SECTION_H = False
#If IMPLEMENT_SECTION_H = True Then
'Clear the object
Set myRange = Nothing
#End If
End Sub
Bookmarks