Looking for some help with code that is not working on windows 7 machines at work but does work on all the Windows XP machines. It is difficult to test because I am still on the dinosaur XP and do not get the error. I have tried to troubleshoot via Webex, but that is painfully slow....looking for help. Here is the code.
The users are getting an error message at the
YourResult = .Find(What:=Sheet1.Range("c" & x), After:=.Cells(1, 1), _
LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False).Offset(0, q)
line....they are getting an Error 91: Object Variable or With Block not set.
Can anyone offer any suggestions for working around this issue or as to why it would not work in Windows 7?
Code:
Sub ChangeFormDataToPrevailTablet()
'Do the locations match?
Application.ScreenUpdating = False
Sheet1.Activate
Dim Answer As String
Dim MyNote As String
Dim YourResult As String
If Left(Sheet1.Range("a11").Value, 5) <> Left(Sheet9.Range("h6"), 5) Then
'Place your text here
MyNote = "Your Prevail Location does not match the -Change Form- location. Do you want to continue? Click Yes to proceed or No to fix this issue."
'Display MessageBox
Answer = MsgBox(MyNote, vbQuestion + vbYesNo, "Question?")
If Answer = vbNo Then
Sheet1.Activate
Sheet1.Range("b1").Select
Exit Sub
'Code for No button Press
Else
GoTo line1
'Code for Yes button Press
End If
End If
line1:
Call Sheet9.ClearNonRed
Sheet1.Activate
Dim match1 As Variant
v = 11
Do Until Sheet1.Cells(v, 3) = ""
v = v + 1
Loop
h = 7
Do Until Sheet9.Cells(9, h) = "Notes:"
h = h + 1
Loop
Dim LastRow As Integer
Dim LastColumn As Integer
Dim RunVariable As Integer
LastRow = v
LastColumn = h - 4
'Loop for the number of weeks in the change form.
q = 3
Do Until q = LastColumn
'Loop for the number of skus in the Prevail Tablet.
x = 11
Do Until x = LastRow
If WorksheetFunction.CountIf(Sheet9.Range("d:d"), Sheet1.Range("c" & x)) > 0 Then
With Sheet9.Range("d:d")
YourResult = .Find(What:=Sheet1.Range("c" & x), After:=.Cells(1, 1), _
LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False).Offset(0, q)
If YourResult = "" Then GoTo line43
End With
Sheet1.Cells(x, q + 5).Select
Selection.Value = vourresult
With Selection.Interior
.ColorIndex = 7
.Pattern = xlSolid
End With
End If
line43:
x = x + 1
Loop
q = q + 1
Loop
Sheet1.Range("g11:x" & LastRow - 1).Select
Selection.Copy
Application.ScreenUpdating = True
End Sub
YourResult = .Find(What:=Sheet1.Range("c" & x), After:=.Cells(1, 1), _
LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False).Offset(0, q)
line....they are getting an Error 91: Object Variable or With Block not set.
Can anyone offer any suggestions for working around this issue or as to why it would not work in Windows 7?