Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default VB Delete Sheets

Hello,
I am a VB Novice and need help.

My code allows the creation and naming of worksheets
according to user input into a list. If the user updates
or adds to the list, I want the worksheets to be deleted
and replaced with the updated versions, by using only a
single menu item.

Because of the user input, I cannot specify a fixed array
of sheet names. How can I specify an array that depends
on the user input? (The list of sheet names specified by
the user is a named range, but the array command did not
work.)

I tried: Sheets(array(range("User_List"))).delete
I also tried: Sheets(array("User_List")).delete


Thanks!
LJones
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 340
Default VB Delete Sheets

LJ, try (untested)

on error resume next
dim oS as object
for each cell in Range("user_list")
if not isempty(cell) then
set oS = nothing
set oS = sheets(cell.value)
if oS is nothing then
msgbox "Sheet " & cell.value & " does not exist. Activity
halted"
exit sub
end if
end if
next
on error goto 0

application.displayalerts = false
For each cell in Range("User_list")
if not isempty(cell) then sheets(cell.value).delete
Next
application.displayalerts = true

Robert Flanagan
Macro Systems
Delaware, U.S. 302-234-9857
http://www.add-ins.com
Productivity add-ins and downloadable books on VB macros for Excel

Application.display
"LJones" wrote in message
...
Hello,
I am a VB Novice and need help.

My code allows the creation and naming of worksheets
according to user input into a list. If the user updates
or adds to the list, I want the worksheets to be deleted
and replaced with the updated versions, by using only a
single menu item.

Because of the user input, I cannot specify a fixed array
of sheet names. How can I specify an array that depends
on the user input? (The list of sheet names specified by
the user is a named range, but the array command did not
work.)

I tried: Sheets(array(range("User_List"))).delete
I also tried: Sheets(array("User_List")).delete


Thanks!
LJones



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default VB Delete Sheets

It worked! Thanks! I never considered this approach, got
too hung up on the "Array" statement.

-----Original Message-----
LJ, try (untested)

on error resume next
dim oS as object
for each cell in Range("user_list")
if not isempty(cell) then
set oS = nothing
set oS = sheets(cell.value)
if oS is nothing then
msgbox "Sheet " & cell.value & " does not

exist. Activity
halted"
exit sub
end if
end if
next
on error goto 0

application.displayalerts = false
For each cell in Range("User_list")
if not isempty(cell) then sheets(cell.value).delete
Next
application.displayalerts = true

Robert Flanagan
Macro Systems
Delaware, U.S. 302-234-9857
http://www.add-ins.com
Productivity add-ins and downloadable books on VB macros

for Excel

Application.display
"LJones" wrote in

message
...
Hello,
I am a VB Novice and need help.

My code allows the creation and naming of worksheets
according to user input into a list. If the user

updates
or adds to the list, I want the worksheets to be deleted
and replaced with the updated versions, by using only a
single menu item.

Because of the user input, I cannot specify a fixed

array
of sheet names. How can I specify an array that depends
on the user input? (The list of sheet names specified

by
the user is a named range, but the array command did not
work.)

I tried: Sheets(array(range("User_List"))).delete
I also tried: Sheets(array("User_List")).delete


Thanks!
LJones



.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default VB Delete Sheets

Application.DisplayAlerts = False
for each cell in Range("User_List)
sheets(cell.value).Delete
Next
Application.DisplayAlerts = True

or
Application.DisplayAlerts = False
varr = Range("UserList")
Sheets(application.Transpose(varr)).Delete
Application.DisplayAlerts = True

if userlist has more than 5461 cells, then this could cause a problem in
some versions of excel. However, I doubt that is the case.

--
Regards,
Tom Ogilvy

"LJones" wrote in message
...
Hello,
I am a VB Novice and need help.

My code allows the creation and naming of worksheets
according to user input into a list. If the user updates
or adds to the list, I want the worksheets to be deleted
and replaced with the updated versions, by using only a
single menu item.

Because of the user input, I cannot specify a fixed array
of sheet names. How can I specify an array that depends
on the user input? (The list of sheet names specified by
the user is a named range, but the array command did not
work.)

I tried: Sheets(array(range("User_List"))).delete
I also tried: Sheets(array("User_List")).delete


Thanks!
LJones



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
macro-delete all sheets except puiuluipui Excel Discussion (Misc queries) 6 October 13th 09 05:49 AM
delete all sheets except... caroline Excel Programming 4 May 22nd 04 04:29 PM
Delete Sheets Jahsonn Excel Programming 1 April 26th 04 01:42 PM
Delete Sheets SS[_3_] Excel Programming 2 February 5th 04 02:37 PM
Delete new sheets? ianripping[_27_] Excel Programming 1 January 17th 04 02:14 PM


All times are GMT +1. The time now is 06:51 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"