Macro that work from another sheet when my worksheet is hidden

Jeffreyxx01

Board Regular
Joined
Oct 23, 2017
Messages
156
Hi

I need my macro to work from another sheet when my worksheet is hidden

Can anyone help and explain how to do it,

Code:
Sub Date_Change_Weekly()'
' Date_Change_Weekly Macro
'
Dim Sht As Worksheet


Set Sht = ActiveWorkbook.Sheets("Pipeline")


Sht.Cells.FormulaR1C1 = "=TODAY()"
    Range("BK1").Select
    Selection.Copy
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Application.CutCopyMode = False
End Sub
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
A few questions
Which sheet is hidden?
Which sheet is Range("BK1") on?
What are you trying to do with this line
Code:
Sht.Cells.FormulaR1C1 = "=TODAY()"
At the moment that will try (and probably fail) to put today's date into every single cell on sheet Pipeline
 
Upvote 0
The below should work for you, but what exactly are you trying to do? This code will write a formula to every single cell on the sheet and then copy/paste value one of the cells.

Code:
Sub Date_Change_Weekly() 
' Date_Change_Weekly Macro
'


With Sheets("Pipeline")
    .Cells.Formula = "=TODAY()!"
    With .Range("BK1")
        .Formula = .Value
    End With
End With






End Sub
 
Upvote 0
Hi

I tried to get the macro work on the sheet("Pipeline") with the formula =Today() in the cell BK1 and copy paste the date in value after it has adjusted on the day using a button on the sheet Macro
 
Upvote 0
That will put the date into every cell on the sheet. And I seriously doubt it will do it...it will most likely throw a memory error.

Anyhow, what are you trying to do?

BTW, for the date in one cell, you can just use:

Code:
Range("A1") = Date

or whatever range you want. Then you don't need to paste values. It puts the actual date (I.E. not a formula) into a range.
 
Last edited:
Upvote 0
Try
Code:
Sub Date_Change_Weekly()
' Date_Change_Weekly Macro
'

With Sheets("Pipeline")
  .Range("BK1") = Date
End With
End Sub
 
Upvote 0
How about
Code:
Sub Date_Change_Weekly() '
' Date_Change_Weekly Macro
'
   Sheets("Pipeline").Range("BK1").Value = Date
End Sub
 
Upvote 0
Thanks guys,
both code are working,
Can you explain whats the way to get a macro working using a button from another worksheet that is hidden,
Thanks
 
Upvote 0
If the worksheet is hidden, you can't click the button so...

I mean, you can call that routine from anywhere you want by putting the name in it's own line of code, but you can't physically click a button that you can't see.
 
Upvote 0
I meant,
I have a tab named Macros where I execute my routine, but the worksheet where the routine is executed is hidden,
I supposed I have to write as the guys did


Code:
Sheets("name worksheet")

if I am correct?
 
Upvote 0

Forum statistics

Threads
1,223,908
Messages
6,175,304
Members
452,633
Latest member
DougMo

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