You are here:

Excel/Write a link to the next sheet


Sorry to pester you twice in one day.  I am trying to replace the VBA below to something quicker and without using Paste Link.  One challenge is the sheets do not have constant names or numbers.

'Update Run History
   'Select Previous Run Sheet
   'Copy from Previous Run Sheet
   'Select Newest Run
   'Paste Link on Newest Run Sheet
       ActiveSheet.Paste Link:=True
   'Copy Current Run Data Row
   'Paste Link For Current Run Data
       Range("A65536").End(xlUp).Offset(1, 0).Select
       ActiveSheet.Paste Link:=True

I guess the new code would look something like this but obviously the second half is not going to work:
Range("A65536").End(xlUp).Formula = "=ActiveSheet.Next.Range("A502:CA502")"

Thanks again for all your help!


If I read you code, on the first activesheet, you find the last cell with data in column A and then overwrite that cell and anything in that row with a link to the next sheet
then you dropdown one row and write a formula to link to the cell above.  So you end up with two identical rows (but with different formulas.  The code below does that.   Test it on a copy of your workbook and see if that is what you want.  

NOTE:  It assumes the next sheet does not have a space in the name.  

Sub abc()
Dim sh As Worksheet
Dim sh1 As Worksheet
Dim r As Range
Set sh = ActiveSheet
Set sh1 = ActiveSheet.Next
Set r = sh.Cells(sh.Rows.Count, 1).End(xlUp)
r.Resize(1, 79).Formula = "=" & sh1.Name & "!A$502"
r.Offset(1, 0).Resize(1, 79).Formula = "=" & r.Address(1, 0)
End Sub

Tom Ogilvy  
About Excel
This topic answers questions related to Microsoft Excel spreadsheet (or workbook) stand-alone or Mircrosoft Office Excel including Excel 2003, Excel 2007, Office 2000, and Office XP. You can get Excel help on Excel formulas(or functions), Excell macros, charting in Excel, advanced features, and the general use of Excel. This does not provide a general Excel tutorial nor the basics of using a spreadsheet. It provides specific answers to using Microsoft Excel only. If you do not see your Excel question answered in this area then please ask an Excel question here


All Answers

Answers by Expert:

Ask Experts


Tom Ogilvy


Selected as an Excel MVP by Microsoft since 1999. Answering Excel questions in Allexperts since its inception in 2001. Able to answer questions on almost all aspects of Excel's internal capabilities. If seeking a VBA solution, please specify that in your question itself so I give you the answer you want. [Excel has weak protection - if you are distributing an application, I don't answer questions on how to protect your project from your users.]


Extensive experience.

Master of Science (MS) degree Operations Research (ORSA)

Awards and Honors
Microsoft MVP in Excel.

©2017 All rights reserved.