Having a variable stored based on date location

Streetsweeper

New Member
Joined
May 7, 2021
Messages
15
Office Version
  1. 365
Platform
  1. Windows
Currently the code is,

Sheets(“Sheet1”).Range(“b18”) = x

The answer to x is stored in b18

Id like to instead. Have x stored in row18 but in a column with today’s date.

If today’s date is May7 which is in cell J5, I would like x to save to J18. If the date was May8 then save to K18.
I’m also trying to focus on today’s date and highlight the column. But that might have to be another post after I get this going.
cheers
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Welcome to MrExcel Message Board.
Please Define What is Range of Date inputted at your sheet. For Example : B5 to Z5
or Upload example image or file with XL2BB ADDIN (Preferable) oR At free hosting site e.g. www.dropbox.com, GoogleDrive , .... And Insert link here.
 
Upvote 0
Try this. Change "x" with the values you want:
VBA Code:
Dim j As Long
For j = 2 To 33
If Sheets("Sheet1").Cells(4, j).Value = Date Then Sheets("Sheet1").Cells(18, j).Value = "x"
Next j
 
Upvote 0

Forum statistics

Threads
1,215,008
Messages
6,122,672
Members
449,091
Latest member
peppernaut

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