PDA

View Full Version : [SOLVED] Can these instructions be consolidated?



K. Georgiadis
03-16-2005, 07:13 PM
I have below two fragments of code that require no explanation:



Worksheets.Add.Name = "Detail"
Worksheets("Detail").Move Before:=Worksheets("Summary")


What is the syntax for creating the new worksheet "Detail" before worksheet "Summary" in the first place, eliminating the need for the move method?

Jacob Hilderbrand
03-16-2005, 07:55 PM
Sheets.Add Before:=Sheets("Summary")

K. Georgiadis
03-16-2005, 08:08 PM
Won't this simply add an untitled new sheet before the sheet titled "Summary?" What I wanted to do was to name the new sheet "Detail". As I indicated in my original post, I know how to do it with two separate instructions (first create, then move). I was wondering if it can be done in a single step.

Jacob Hilderbrand
03-16-2005, 08:14 PM
You will still need two lines to set the position and the name.

K. Georgiadis
03-16-2005, 08:23 PM
Good to know, so that I don't waste any time look for the "more elegant" code. As always, thanks for your help

Jacob Hilderbrand
03-16-2005, 08:49 PM
You're Welcome :beerchug:

Take Care