PC Review


Reply
Thread Tools Rate Thread

ADDING/DELETING SHEETS WITHOUT LOSING FOCUS.

 
 
Faraz A. Qureshi
Guest
Posts: n/a
 
      29th Jul 2009
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
 
Reply With Quote
 
 
 
 
Bob Phillips
Guest
Posts: n/a
 
      29th Jul 2009
Dim sh As Worksheet

Set sh = ActiveSheet
Worksheets.Add before:=Worksheets(1)
sh.Activate


--
__________________________________
HTH

Bob

"Faraz A. Qureshi" <(E-Mail Removed)> wrote in
message news:77D77ABE-1BAF-4897-BD20-(E-Mail Removed)...
>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



 
Reply With Quote
 
Faraz A. Qureshi
Guest
Posts: n/a
 
      29th Jul 2009
Thanx Bob!

However, this code I believe shall work only with a single sheet selected.
But what I have is a question pertaining to multiple sheets selected?

--
Best Regards,

Faraz


"Bob Phillips" wrote:

> Dim sh As Worksheet
>
> Set sh = ActiveSheet
> Worksheets.Add before:=Worksheets(1)
> sh.Activate
>
>
> --
> __________________________________
> HTH
>
> Bob
>
> "Faraz A. Qureshi" <(E-Mail Removed)> wrote in
> message news:77D77ABE-1BAF-4897-BD20-(E-Mail Removed)...
> >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

>
>
>

 
Reply With Quote
 
MichDenis
Guest
Posts: n/a
 
      29th Jul 2009
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 before:=Sheets(1)
Sh.Select
.Sheets(X).Activate
End With
End Sub
'------------------------------

"Faraz A. Qureshi" <(E-Mail Removed)> a écrit dans le message de
groupe de discussion : 77D77ABE-1BAF-4897-BD20-(E-Mail Removed)...
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

 
Reply With Quote
 
Faraz A. Qureshi
Guest
Posts: n/a
 
      29th Jul 2009
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 before:=Sheets(1)
> Sh.Select
> .Sheets(X).Activate
> End With
> End Sub
> '------------------------------
>
> "Faraz A. Qureshi" <(E-Mail Removed)> a écrit dans le message de
> groupe de discussion : 77D77ABE-1BAF-4897-BD20-(E-Mail Removed)...
> 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
>
>

 
Reply With Quote
 
MichDenis
Guest
Posts: n/a
 
      29th Jul 2009
X = ActiveSheet.Name



"Faraz A. Qureshi" <(E-Mail Removed)> a écrit dans le message de
groupe de discussion : 735D5AB0-6C02-486D-86F3-(E-Mail Removed)...
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 before:=Sheets(1)
> Sh.Select
> .Sheets(X).Activate
> End With
> End Sub
> '------------------------------
>
> "Faraz A. Qureshi" <(E-Mail Removed)> a écrit dans le message de
> groupe de discussion : 77D77ABE-1BAF-4897-BD20-(E-Mail Removed)...
> 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
>
>

 
Reply With Quote
 
norie
Guest
Posts: n/a
 
      29th Jul 2009
Here's my go.
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
ADDING/DELETING SHEET Without losing focus? Faraz A. Qureshi Microsoft Excel Misc 1 29th Jul 2009 12:55 PM
Adding And Deleting Sheets =?Utf-8?B?QW5pY2U=?= Microsoft Excel Programming 1 26th Jun 2006 03:51 PM
Intercept Lost"focus" without losing focus... Stefan De Schepper Microsoft VB .NET 0 13th Jul 2005 08:33 PM
set focus for field just losing focus AngiW Microsoft Access VBA Modules 3 3rd Feb 2004 06:07 AM
How to control sheet number when adding and deleting sheets? ChuckM Microsoft Excel Programming 0 28th Jan 2004 05:52 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:54 AM.