Error after date: 10-10-2021

m gruwel

New Member
Joined
Oct 25, 2021
Messages
1
Office Version
  1. 365
Platform
  1. Windows
Hello,

I wrote and starting using the code at the start of 2021. Somewere around 2-2021. It worked perfect until two weeks ago. I think it has something to do with the date value, for it does not work after 09-10-2021.
the code works as follows:
I enter a date in B3 sheet AFVAL_TOT. In sheet AFVAL_DATA is a list ranging from 1-1-2021 to 31-12-2021. when i press the button (which starts the code) it will take the values from worksheet AFVAL_TOT and copy it to worksheet AFVAL_DATA in the list with dates behind the date thats corresponds with the date from B3.

Sub Knop()
Dim rFndCell As Range
Dim stFnd As Date
Dim fRow As Long
Dim sh As Worksheet
Dim ws As Worksheet

Set ws = Sheets("AFVAL_TOT")
Set sh = Sheets("AFVAL_DATA")
stFnd = Range("B3")

With sh
Set rFndCell = .Range("D2:D366").Find(stFnd, LookIn:=xlValues)
If Not rFndCell Is Nothing Then
fRow = rFndCell.Row
ws.Range("C5,D5").Copy sh.Cells(fRow, 5)
ws.Range("C6,D6").Copy sh.Cells(fRow, 7)
ws.Range("C7,D7").Copy sh.Cells(fRow, 9)
ws.Range("C8,D8").Copy sh.Cells(fRow, 11)
ws.Range("C9,D9").Copy sh.Cells(fRow, 13)
ws.Range("C10,D10").Copy sh.Cells(fRow, 15)
ws.Range("C11").Copy sh.Cells(fRow, 17)
ws.Range("C12").Copy sh.Cells(fRow, 18)
ws.Range("C14,D14").Copy sh.Cells(fRow, 19)
MsgBox "Ok"
Else
MsgBox "Error"
End If
End With
End Sub
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Welcome to the MrExcel Message Board!

Cross-posting (posting the same question in more than one forum) is not against our rules, but the method of doing so is covered by #13 of the Forum Rules.

Be sure to follow & read the link at the end of the rule too!

Cross posted at: Error after date: 10-10-2021
If you have posted the question at more places, please provide links to those as well.

If you do cross-post in the future and also provide links, then there shouldn’t be a problem.
 
Upvote 0

Forum statistics

Threads
1,214,924
Messages
6,122,294
Members
449,077
Latest member
Rkmenon

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