Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How to select multiple sheets in VBA?


Hi all,

I'm trying to create a macro/program that when execute will:

1. Ask user to select and open an Excel file.
--archieved this by using GetOpenFile method.
2. Ask user to select multiple sheets in the opened file.
--GOT STUCK here.
3. Copy some infos from the selected sheets to other sheet in othe
file.

I'm stuck in 2. How do I ask user to select multiple sheets?

I tried to open the file and loop through th
Activewindow.Selectedsheet, but only one sheet was selected. There i
no dialog to temporarily stop the macro and ask user to select th
sheets. Any idea how can I solve this

--
hidek
-----------------------------------------------------------------------
hideki's Profile: http://www.excelforum.com/member.php...fo&userid=1890
View this thread: http://www.excelforum.com/showthread.php?threadid=49236

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default How to select multiple sheets in VBA?

Hi Hideki,

One way:

'=============
Sub Tester()
Dim strInput As String
Dim arr As Variant
Dim i As Long
Dim SH As Worksheet
Dim blOK As Boolean

blOK = True

strInput = InputBox(Prompt:="Please enter sheet " _
& "names separated with a comma" _
& vbNewLine & "e.g.:" _
& "Sheet1, Sheet3,Sheet5", _
Default:="Sheet1")

If StrPtr(strInput) = 0 Then
MsgBox "You pressed Cancel"
Exit Sub
Else
If Len(strInput) = 0 Then
MsgBox "OK was pressed but no entry was made."
Exit Sub
Else
arr = Split(strInput, ",")
For i = LBound(arr) To UBound(arr)
Sheets((arr(i))).Select blOK
blOK = False
Next i
End If
End If

'To demonstrate selection:
For Each SH In ActiveWorkbook.Windows(1).SelectedSheets
MsgBox SH.Name
Next

End Sub
'<<=============

---
Regards,
Norman


"hideki" wrote in
message ...

Hi all,

I'm trying to create a macro/program that when execute will:

1. Ask user to select and open an Excel file.
--archieved this by using GetOpenFile method.
2. Ask user to select multiple sheets in the opened file.
--GOT STUCK here.
3. Copy some infos from the selected sheets to other sheet in other
file.

I'm stuck in 2. How do I ask user to select multiple sheets?

I tried to open the file and loop through the
Activewindow.Selectedsheet, but only one sheet was selected. There is
no dialog to temporarily stop the macro and ask user to select the
sheets. Any idea how can I solve this?


--
hideki
------------------------------------------------------------------------
hideki's Profile:
http://www.excelforum.com/member.php...o&userid=18903
View this thread: http://www.excelforum.com/showthread...hreadid=492366



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How to select multiple sheets in VBA?


Thank you very much Norman. The code works great. This is most likel
what I'm looking for.

Only one drawback is that if I could, I would like the user to selec
the sheets instead of write down the sheet names in the inputbox. Th
best is if the user could click the sheets tab (with Ctrl or Shift key
to make the selection. If that's impossible, may be I could try the use
form with sheet names populate on it and locate a checkbox for the use
to check. But it may take me years to figure out that myself

--
hidek
-----------------------------------------------------------------------
hideki's Profile: http://www.excelforum.com/member.php...fo&userid=1890
View this thread: http://www.excelforum.com/showthread.php?threadid=49236

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default How to select multiple sheets in VBA?

Hi Hideki,
I could try the user
form with sheet names populate on it and locate a checkbox for the user
to check. But it may take me years to figure out that myself.


See John Walkenbach's approach at:

http://www.j-walk.com/ss/excel/tips/tip48.htm

You may be able to emply a simmilar approach.


---
Regards,
Norman



"hideki" wrote in
message ...

Thank you very much Norman. The code works great. This is most likely
what I'm looking for.

Only one drawback is that if I could, I would like the user to select
the sheets instead of write down the sheet names in the inputbox. The
best is if the user could click the sheets tab (with Ctrl or Shift key)
to make the selection. If that's impossible, may be I could try the user
form with sheet names populate on it and locate a checkbox for the user
to check. But it may take me years to figure out that myself.


--
hideki
------------------------------------------------------------------------
hideki's Profile:
http://www.excelforum.com/member.php...o&userid=18903
View this thread: http://www.excelforum.com/showthread...hreadid=492366



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How to select multiple sheets in VBA?


Thank you very much, Norman. The link that you gave really help me. B
refering to it, I'd already accomplished the task. Really appreciat
your help.

hideki

--
hidek
-----------------------------------------------------------------------
hideki's Profile: http://www.excelforum.com/member.php...fo&userid=1890
View this thread: http://www.excelforum.com/showthread.php?threadid=49236



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
Why when I select multiple sheets they are not highlighted in 07? jeffw Excel Discussion (Misc queries) 0 March 26th 08 06:27 PM
Multiple Sheets (Need to create 500 individual sheets in one workbook, pulling DATA Amaxwell Excel Worksheet Functions 4 August 17th 06 06:23 AM
Select Multiple sheets Steve Excel Discussion (Misc queries) 1 October 7th 05 06:14 PM
in charting, how do i select data ranges from multiple sheets, sa. michael Charts and Charting in Excel 1 March 6th 05 03:01 PM
select sheets by name - how? Walt[_2_] Excel Programming 5 July 30th 03 10:42 PM


All times are GMT +1. The time now is 05:45 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"