Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Formula Referencing Worksheet Name by Variable
Concatenation should work:
Set OldSht = ActiveSheet Sheets.Add NewShtName = ActiveSheet.Name OldSht.Activate Cells(1, 1).Formula = "='" & NewShtName & "'!A2" "dafio" wrote: I am setting up a macro that will add a new worksheet to a workbook. The macro will then need to enter a formula in a cell on an existing worksheet that references a cell on the new worksheet. I am assuming I can use a variable for the new worksheet name and concatenate it within the formula but it doesn't work. e.g. - If the new worksheet is named "Smith", I would need to use VBA to enter the following formula on an existing worksheet: =Smith!A2 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Replace worksheet without affecting the referencing formula | Excel Discussion (Misc queries) | |||
Variable Worksheet Name in Formula | Excel Worksheet Functions | |||
Same formula referencing same cells returns incorrect results, randomly, when pasted into new worksheet | Excel Worksheet Functions | |||
referencing worksheet as a variable | Excel Programming | |||
Referencing variable | Excel Programming |