• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Run code without changing sheet and ending on a cell

Hi,
I am very basic in VB and failing to perform a task I have completed in the past.

How to execute code on a sheet without changing wherever a person is in the book. The below code inelegantly copies cells and pastes formula onwards. Basically this then allows columns to be inserted and then writes the formula in every minute.

So I would like some tips please on how I can execute the code without anyone ever knowing it has run?

Code:
Sub UpdateCells()
Application.OnTime Now + TimeValue("00:01"), "UpdateCells"
Application.ScreenUpdating = False
Sheets("Test").Select
    Range("p1:p6").Select
   Selection.AutoFill Destination:=Range("p1:zz6"), Type:=xlFillDefault
  '  Range("p1:zz6").Select
 
Application.ScreenUpdating = True

End Sub


Thanks for looking and any advice.

-CL
 
Last edited:
Try this:

Code:
Sub UpdateCells()
   Application.OnTime Now + TimeValue("00:01"), "UpdateCells"
   With Sheets("Test")
      .Range("p1:p6").AutoFill Destination:=.Range("p1:zz6"), Type:=xlFillDefault
   End With
  
End Sub
 
Last edited:
Back
Top