VBA code works on works desktop but not on my own laptop

Monojono

New Member
Joined
Nov 20, 2020
Messages
15
Office Version
  1. 365
Platform
  1. Windows
Hello Readers and hopefully problem solvers,

I have a large amount of coding across my workbook that works fine on my works desktop. However, on my laptop one small sub routine stops half way into the code and I can't seem to find the answer to getting it working.

As I said and code works OK on my works desktop but not on my laptop.

The code is as follows:

Sub NoneGasRoundEntrie()

Sheets("SCORECARD").Select

Range("AV7").Value = Range("P3").Value

Range("AV7").Select

Dim GolferX As Range

Set GolferX As ActiveCell

Sheets("INDEX").Select

Range("C10:C111").Find(GolferX).Select

ActiveCell.Offset(0, 5).Select

Call MoveOldRounds

ActiveCell.Offset(0, 19).Select

ActiveCell = Sheets("SCORECARD").Range("AV6").Value

Call IndexFormula

Sheets("SCORECARD").Select

Range("B4").Select

End Sub

The line in YELLOW above is where the code stops.

The desktop is using Office 365 Pro Plus and my laptop is using Office 365

Please please help.

Kind Regards,

Mono
 
Wat are your Macro Security Settings on your laptop?
Are you able to run other Macros on it?

Are all your drive mappings the same on your laptop as your other computer?
 
Upvote 0

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
The code is same, but is it data in the worksheet same?
It can be error if in this new worksheet in the specified range "Range("C10:C111")" there is no cell that you are looking for.
Try to add "On Error Resume Next" before problematic line.

VBA Code:
On Error Resume Next
    Range("C10:C111").Find(GolferX).Activate
 
Upvote 0
Wat are your Macro Security Settings on your laptop?
Are you able to run other Macros on it?

Are all your drive mappings the same on your laptop as your other computer?
I can ran other Macro

Don't know how to check drive mappings
 
Upvote 0
The code is same, but is it data in the worksheet same?
It can be error if in this new worksheet in the specified range "Range("C10:C111")" there is no cell that you are looking for.
Try to add "On Error Resume Next" before problematic line.

VBA Code:
On Error Resume Next
    Range("C10:C111").Find(GolferX).Activate
It it definitely there, I can see it in cell C23 on Sheet INDEX
 
Upvote 0
The code is same, but is it data in the worksheet same?
It can be error if in this new worksheet in the specified range "Range("C10:C111")" there is no cell that you are looking for.
Try to add "On Error Resume Next" before problematic line.

VBA Code:
    Dim varFind
    varFind = Range("C10:C111").Find(GolferX).Activate
    If varFind Then
        MsgBox (GolferX)
    Else
        MsgBox ("There is no " & GolferX)
    End If
 
Upvote 0
Solution
The code is same, but is it data in the worksheet same?
It can be error if in this new worksheet in the specified range "Range("C10:C111")" there is no cell that you are looking for.
Try to add "On Error Resume Next" before problematic line.

VBA Code:
    Dim varFind
    varFind = Range("C10:C111").Find(GolferX).Activate
    If varFind Then
        MsgBox (GolferX)
    Else
        MsgBox ("There is no " & GolferX)
    End If
Thanks Max the on error resume next seems to of sorted it

Now I've got an 100 mini sub routines to amend, happy days

Thanks Max
 
Upvote 0
It's my pleasure.
"On Error Resume Next" it's not 100% secure.
If code is too long it will very soon create new problems.
Always use variable to check trute like in my second example.
 
Upvote 0
It is important to be fully aware of what the "On Error Resume Next" line does. Basically, it tells you that if it finds an error, just to ignore it and continue on with the code. That could, however, be very problematic if your code depends on what is happening in that step. For instance, if it is supposed to be finding some value in the range, and it doesn't find it, what are the ramifications of proceeding in the code?

For example, if your code was doing something like deleting lines, it could end up deleting lines that you don't want deleted!
Since we do not really know what your "IndexFormula" procedure does, we really cannot say what the potential ramifications are.

Typically, I will add "error handling" code to my VBA code which does NOT ignore the errors, but rather either reports them, aborts the procedure, or takes some specific action based on what the error is.
 
Upvote 0
@Monojono, with Find you would normally set the result it to a variable and then test if it exists rather than use On Error Resume Next, something like the below (you also wouldn't normally use all those Selects and Activates but I can't do anything with that as I don't know what your other 2 macro's are doing).

You also shouldn't be getting an Error 9 Subscript out of range error if the value isn't found, you should get an Error 91 Object variable or With block variable not set.

VBA Code:
Sub NoneGasRoundEntrie()
    Dim GolferX As Range, nVar As Range
   
    With Sheets("SCORECARD")
        .Range("AV7").Value = .Range("P3").Value
        Set GolferX = .Range("AV7")
    End With
   
    Sheets("INDEX").Select

    Set nVar = Range("C10:C111").Find(GolferX)
   
    If Not nVar Is Nothing Then
       
        nVar.Offset(0, 5).Select

        Call MoveOldRounds

        ActiveCell.Offset(0, 19).Select

        ActiveCell = Sheets("SCORECARD").Range("AV6").Value

        Call IndexFormula

        Application.Goto Sheets("SCORECARD").Range("B4")
    Else
        Exit Sub
    End If

End Sub

It also isn't a good idea to use Find without defining the appropriate parameters as Find retains a memory on certain parameters.
 
Upvote 0

Forum statistics

Threads
1,214,540
Messages
6,120,107
Members
448,945
Latest member
Vmanchoppy

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