LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Referencing previous worksheets in formula


I am working on a macro to copy the last worksheet in a workbook at the
end of the existing worksheets and input formulas in the new worksheet
that reference the previous worksheet.

For example, consider the following code:

Dim ws As Worksheet

Set ws = Worksheets(Worksheets.Count)
ws.Copy After:=ws
Set ws = Worksheets(Worksheets.Count)
ws.Range("A1").Formula = “=’Sheet1’!A1 + 1”

How can I replace the ‘Sheet1’ name with the name of the previous
worksheet?

My attempt that resulted in a run-time error was:

ws.Range("A1").Formula =
“=Worksheets(Worksheets.Count-1).Range(“A1”) + 1”


Any suggestions are appreciated.

Thanks,

Carey


--
cnaquin
------------------------------------------------------------------------
cnaquin's Profile: http://www.excelforum.com/member.php...o&userid=26242
View this thread: http://www.excelforum.com/showthread...hreadid=395345

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy worksheet to new doc w/formulas not referencing previous doc Feolet20 Excel Discussion (Misc queries) 4 June 30th 09 10:56 PM
Formula - Referencing Between Worksheets 1S2RSK Excel Discussion (Misc queries) 1 January 2nd 08 07:18 AM
Array formula referencing other worksheets broderp Excel Worksheet Functions 1 December 8th 06 09:27 PM
Formula Referencing data on multiple worksheets ChrisPrather Excel Worksheet Functions 6 August 22nd 06 05:14 AM
Referencing previous column in COUNTIF [email protected] Excel Discussion (Misc queries) 6 March 1st 05 10:27 AM


All times are GMT +1. The time now is 11:33 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"