Working Macro to Move onto Tab

Roj47

Board Regular
Joined
May 4, 2011
Messages
71
Office Version
  1. 365
Platform
  1. Windows
Many, many thanks to VoG for the following Macro :

Sub Copy_Formula()
'
' Copy_Formula Macro
' Macro recorded 04/05/2011 by Littlefair
'
'
Dim LR As Long
LR = Cells.Find(What:="*", SearchDirection:=xlPrevious, SearchOrder:=xlByRows).Row - 1
Range("R11:AQ11").Copy
Range("R12:AQ" & LR).PasteSpecial Paste:=xlFormulas
Application.CutCopyMode = False
End Sub

However, I am trying to have it run when a tab is selected. I have amended to the following to copy the formula on the sheet as shown, but it does not run to the bottom as the Picture allocated one does.

Where have I gone wrong please and how do I get it to work?

Thanking in advance for any assistance

Sub Copy_Formula()
'
' Copy_Formula Macro
' Macro recorded 04/05/2011 by Littlefair
'
'
Private Sub Worksheet_Activate()
Dim LR As Long
LR = Cells.Find(What:="*", SearchDirection:=xlPrevious, SearchOrder:=xlByRows).Row - 1
Sheets("VTC Detailed").Range("R11:AQ11").Copy
Application.EnableEvents = False
Sheets("VTC Detailed").Range("R12:AQ188").PasteSpecial Paste:=xlFormulas, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Sheets("VTC M&E Summary").Activate
Application.EnableEvents = True
End Sub
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
I noted a mistake in the code (highlighted amendment in red), but unfortunately this is still failing miserably.

Do you have any suggestions for me to pick up the formula to run to the bottom of the list when I select a tab.

Many thanks.

Sub Copy_Formula()
'
' Copy_Formula Macro
' Macro recorded 04/05/2011 by Littlefair
'
'
Private Sub Worksheet_Activate()
Dim LR As Long
LR = Cells.Find(What:="*", SearchDirection:=xlPrevious, SearchOrder:=xlByRows).Row - 1
Sheets("VTC Detailed").Range("R11:AQ11").Copy
Application.EnableEvents = False
Sheets("VTC Detailed").Range("R12:AQ" & LR).PasteSpecial Paste:=xlFormulas, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Sheets("VTC M&E Summary").Activate
Application.EnableEvents = True
End Sub
 
Upvote 0
Closed out:

Sorry guys, really not wanting to spam or bump this at all.

Figured the problem through trial and error from a working VoG solution :

Sub Copy_Formula()<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>
'<o:p></o:p>
' Copy_Formula Macro<o:p></o:p>
' Macro recorded 04/05/2011 by Littlefair<o:p></o:p>
'<o:p></o:p>
'<o:p></o:p>
Private Sub Worksheet_Activate()<o:p></o:p>
Dim LR As Long<o:p></o:p>
LR = Sheets("VTC Detailed").Cells.Find(What:="*", SearchDirection:=xlPrevious, SearchOrder:=xlByRows).Row - 1<o:p></o:p>
Sheets("VTC Detailed").Range("R11:AQ11").Copy<o:p></o:p>
Application.EnableEvents = False<o:p></o:p>
Sheets("VTC Detailed").Range("R12:AQ" & LR).PasteSpecial Paste:=xlFormulas<o:p></o:p>
Sheets("VTC M&E Summary").Activate<o:p></o:p>
Application.EnableEvents = True<o:p></o:p>
Application.CutCopyMode = False<o:p></o:p>
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,595
Messages
6,179,799
Members
452,943
Latest member
Newbie4296

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