error 5 - Invalid procedure call or argument

kazbear

New Member
Joined
Dec 16, 2002
Messages
42
Office Version
  1. 365
Platform
  1. Windows
All my users started to get this error last week. They all use a copy of the same spreadsheet and its been in use for a couple years with no issues.

Its a basic production sheet, and I have added simple buttons that will increase (and some to decrease) a number each time its pushed. It finds the correct date, then moves to the correct cell to change the number accordingly.

The error happens at this line:

Application.Goto Range("b6:b150").Cells(Application.Match(PresentDate, Range("b6:b150"), 0))

This is a sample of the full action of the button:

Sub IncrementSoldAd()
'


Dim PresentDate As Long
PresentDate = Int(Now())
Application.Goto Range("b6:b150").Cells(Application.Match(PresentDate, Range("b6:b150"), 0))

ActiveCell.Offset(0, 1).Select
soldad = ActiveCell.Value + 1
ActiveCell.Value = soldad


End Sub

Since it all started happening to everyone at the same time, I assume it has something to do with the date. The dates in column "b" are generated using an increment "+1" to the previous cell, like so:
=B134+1

But like I said. It all has worked fine until last week.

Any assistance in tracking down this problem is appreciated
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Really you should test for a match before trying to pass the row position:
Code:
Sub IncrementSoldAd()
'


Dim PresentDate As Long
Dim vMatch
PresentDate = CLng(Date)
vMatch = Application.Match(PresentDate, Range("b6:b150"), 0)
if not iserror(vmatch) then
With Range("C6:C150").Cells(vMatch)
.Value = .Value + 1
End With
else
msgbox "Can't find " & date & " in B6:B150"
End If
End Sub
 
Upvote 0
Thank you.

Well, just seeing the error returned from that change lets me see my mistake... My range stops at 150. Not sure why I did not see that before (Or why its like that to begin with)

Wow. Need another cup of coffee I guess...
 
Upvote 0

Forum statistics

Threads
1,203,620
Messages
6,056,330
Members
444,861
Latest member
B4you_Andrea

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