View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Faraz A. Qureshi Faraz A. Qureshi is offline
external usenet poster
 
Posts: 211
Default ADDING/DELETING SHEETS WITHOUT LOSING FOCUS.

Run-time Error '91':
Object variable or With block variable not set
The following line being highlighted:

X = .ActiveSheet.Name

--
Best Regards,

Faraz


"MichDenis" wrote:

Hi,
Try this :
'------------------------------
Sub test()
Dim Sh As Object, X As String
With Workbooks(ThisWorkbook.Name)
.Activate
Set Sh = ActiveWindow.SelectedSheets
X = .ActiveSheet.Name
.Worksheets.Add befo=Sheets(1)
Sh.Select
.Sheets(X).Activate
End With
End Sub
'------------------------------

"Faraz A. Qureshi" a écrit dans le message de
groupe de discussion : ...
I have a few sheets selected. How to have a new sheet be inserted at the
beginning, or deleting the first sheet, with the currently selected sheets
remaining to be selected.

A proper code for the same shall be obliged.

Thanx in advance.
--
Best Regards,

Faraz