jwburritt

New Member
Joined
May 22, 2019
Messages
49
Office Version
  1. 365
Platform
  1. Windows
Hello: I need a sub to input last month's date into a column of data and then hard code the date. The only solution I came up with is below, but I'm wondering why it's not creating a circular reference. Thank you! I'm sure it has something to do with equivalency, but I'm still new!

Code:
Sub temp()   
    Dim i As Long
    For i = 2 To 4
        Cells(i, 2).Formula = "=EOMONTH(TODAY(),-1)"
        Cells(i, 2).Value = Cells(i, 2).Value
    Next i


End Sub
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
There is no circular reference because the formula does not use the same cell in the calculation.

It can also be like this:

Code:
Sub temp2()
  With Range("B2:B4")
    .Formula = "=EOMONTH(TODAY(),-1)"
    .Value = .Value
  End With
End Sub
 
Last edited:
Upvote 0
I'm glad to help you. Thanks for the feedback.
 
Upvote 0
It can be done even more directly
Code:
Sub temp3()
  Range("B2:B4").Value = Date - Day(Date)
End Sub
 
Upvote 0
It can be done even more directly
Code:
Sub temp3()
  Range("B2:B4").Value = Date - Day(Date)
End Sub

If the range is really fixed and non-changing, this can be shortened to this...
Code:
Sub temp3()
  [B2:B4] = Date - Day(Date)
End Sub
 
Upvote 0

Forum statistics

Threads
1,213,494
Messages
6,113,972
Members
448,537
Latest member
Et_Cetera

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