Beneindias
Board Regular
- Joined
- Jun 21, 2022
- Messages
- 120
- Office Version
- 365
- Platform
- Windows
- MacOS
So, I'm having a problem with some code in VBA, I bet that it's an easy solution, but I'm a noob.
I created a module, to check if it should call another module to sort my table.
This code is throwing me an error "Object required" and it's pointing to the line "If Not Intersect(col, Target) Is Nothing Then".
I don't know how to fix this and already tried a lot of ideas.
This code was working when I had it in the worksheet, but as soon as I created the module, I'm having errors. Already fixed a few, but can't find a solution to this one.
This is in the first worksheet:
This is in a module (chbx is an ActiveX checkbox):
Again, the code that I have in the module was working when I had it directly in the worksheet's code.
Thanks for any help
I created a module, to check if it should call another module to sort my table.
This code is throwing me an error "Object required" and it's pointing to the line "If Not Intersect(col, Target) Is Nothing Then".
I don't know how to fix this and already tried a lot of ideas.
This code was working when I had it in the worksheet, but as soon as I created the module, I'm having errors. Already fixed a few, but can't find a solution to this one.
This is in the first worksheet:
VBA Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Call InstructionsToSort
End Sub
This is in a module (chbx is an ActiveX checkbox):
VBA Code:
Sub InstructionsToSort()
Dim col As Range
Dim chbx As Variant
Set col = ActiveSheet.ListObjects("Abastecimentos").ListColumns("Data").Range
Set chbx = ActiveSheet.AutoSort
If Not Intersect(col, Target) Is Nothing Then
If chbx.Value = True Then
'Selection IS inside the range.
Call SortTable
End If
End If
End Sub
Again, the code that I have in the module was working when I had it directly in the worksheet's code.
Thanks for any help