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
'Copy Current Run Data Row
'Paste Link For Current Run Data
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.
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)
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