Open and format new worksheet without selecting it?
Hi everyone
Below is the start of a procedure to delete an existing worksheet and create
a new worksheet to replace old.
What changes to code is required to:-
If FOOD sheet not included in workbook the Set dt throws up and error, how
do you skip the FOOD delete op. and Add a new FOOD sheet anyway?
How do you code to open a new worksheet give it a tab name and 4 column
title header in A1 to D1 without actually selecting the new sheet?
Sub Test()
Dim dt As Worksheet
Set dt = Worksheets("FOOD")
ActiveWorkbook.Sheets("Where It Goes").Activate
Application.DisplayAlerts = False
Worksheets("FOOD").Delete
Application.DisplayAlerts = True
'
[C2].Value = [J1] enter start date in Where It Goes worksheet.
[G2].Value = [J2] enter finish Date in Where It Goes worksheet.
'
ActiveWorkbook.Sheets.Add After:=Worksheets(Worksheets.Count)
ActiveSheet.Name = "FOOD"
ActiveSheet.Tab.ColorIndex = 4
'
I find it very difficult not to use select and activate each sheet to
achieve the copying and pasting of values formula etc. from one sheet to next
sheet or workbook.
All help greatly appreciated.
--
Thank you
Regards
Bob C
Using Windows XP Home + Office 2003 Pro
|