VBA Code Copy/Replace Values base on Date

Dirtydrongo

New Member
Joined
May 9, 2024
Messages
3
Office Version
  1. 365
Platform
  1. Windows
Hey,

I have the following issue,
I have calculated relevant input data from sheet 'Raw Data Input' which is daily input then cleared after entry this has been formulated to input per the attached.
Desired outcome have the macro search column 'A' for todays date and replace Column 'D to R' with the value on the relevant row.
Additionally the following formula to find the data returns false if not current date therefore cell 'D12' I would like to be blank if not meeting the condition.
Current Formula '=IF(A12=TODAY(),(IF('Raw Data Input'!$B$2="","",VLOOKUP($E$1,'Raw Data Input'!$A$2:$D$1000,2,FALSE))))'
1728354443780.png


Any help would be appreciated.
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Assuming that in column A there are valid Dates, then try
VBA Code:
Sub FreezeVal()
Dim myMatch
'
myMatch = Application.Match(CLng(Date), Range("A:A"), False)
If Not IsError(myMatch) Then
    Cells(myMatch, "D").Resize(1, 15).Value = Cells(myMatch, "D").Resize(1, 15).Value          '****
Else
    MsgBox ("Date not found: " & Format(Date, "dd-mmm-yyyy"))
End If
End Sub
However this will "freeze" only the current Date; so when you execute it on Monday, Sat and Sun rows will not be freezed

Therefore you could consider replacing the row marked '*** with the following:
VBA Code:
    Range(Range("D2"), Cells(myMatch, "R")).Value = Range(Range("D2"), Cells(myMatch, "R")).Value
This will freeze from D2 to colum R of the current day

Try...
 
Upvote 0

Forum statistics

Threads
1,224,812
Messages
6,181,104
Members
453,021
Latest member
Justyna P

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