Macro stopped working

tobyz95

Board Regular
Joined
Jul 28, 2012
Messages
190
Hello ALL, I have been using this macro for years and it has just stopped working and I cannot figure out why.
any help would be greatly appreciated.

VBA Code:
Dim LastFilledCell As Range
    Set LastFilledCell = Range("K76:K80").Find(What:="*", SearchOrder:=xlRows, _
    SearchDirection:=xlPrevious, LookIn:=xlValues)
    If LastFilledCell Is Nothing Then
    Range("K76").Value = "2000"
    ElseIf LastFilledCell.Row < 81 Then
    LastFilledCell.Offset(1) = "2000"
    Else
    MsgBox "Range is completely filled!"
    End If
End Sub

YearlyBudget2023.xlsm
KLMNOPQ
1200.00
2100.00
31,000.00
415.00
5500.00I want the next amount to go to L5, M5,N5 if necessary
6I have a control button that adds a figure so if the five rows get filled when I have to hit the control button, the figure is placed in the next open cell to the right in that row
7
8
9
10
NOVEMBER
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
What does "stopped working" mean? Does it do nothing? Does it do something, but different than what you expect? Do you get error messages? Please be specific.
 
Upvote 0
What are you trying to achieve with this macro? All it does for me is fill in the range K76:K80 with "2000" each time I run it down to K81. And the Message Box never fires.
 
Upvote 0
I want the next amount to go to L5, M5,N5 if necessary
This is nothing at all like what this code actually does. It puts values in K76, then K77, K78, etc., as noted by dreid1011. I think whatever you have been using for years is not the same as what you are showing us.
 
Upvote 0
Thank you all for responding. This macro is assigned to a control button that adds a figure to that area each month. If the five rows get filled when I have to hit the control button, the figure is placed in the next open cell to the right in that row. So, throughout the month I add amounts to column K76:K80 which are actually amounts added to my checking account. Then I have a control button to add an amount at a certain time each month that adds a figure to that area. If the five rows are already filled when I have to hit the control button, the figure is placed in the next open cell to the right which is L80, M80, etc. What I meant by stopped working is that now it puts the figure in K81, (which is in use) instead of moving to the right. I hope this helps.
 
Upvote 0
There is no way this code now or ever populated values to the right. If you ever had code that put data in the next cell to the right, it was not this code. I think you have some sort of version management problem with your code.
 
Upvote 0
What I meant by stopped working is that now it puts the figure in K81, (which is in use) instead of moving to the right. I hope this helps.
Missing a comma
Rich (BB code):
LastFilledCell.Offset(,1) = "2000"
 
Upvote 0
Solution
Mark858,
You did it! I'm not sure how that was removed or what happened there, but I added the comma and it worked. Thank you ever so much for your time and expertise.
It is greatly appreciated, because I am like a dog with a bone trying to figure things out.
You_Rock_Emoticon[1].gif
 
Upvote 0

Forum statistics

Threads
1,215,517
Messages
6,125,290
Members
449,218
Latest member
Excel Master

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