0

How do I enter a formula to display the previous workday into the active cell using VBA. I've only found code that would cause today's date to appear in a message box.

So my code currently ends with:

Selection.Copy
Sheets("Inventory").Select
ActiveSheet.Paste
ActiveCell.Offset(20,4).Select

This pastes some data and then drops the active cell off exactly where I need it. At this point, I want to enter the previous workday, copy it, and paste it in all uninterrupted blank rows above it.

Community
  • 1
  • 1

1 Answers1

0

Maybe

ActiveCell.Value = WorksheetFunction.WorkDay(Date, -1)

Note that you should generally avoid using Select - see How to avoid using Select in Excel VBA for more detail.

BigBen
  • 46,229
  • 7
  • 24
  • 40