Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Hi
I am using the formula below to copy a worksheet, which is then pasted out to another workbook. ThisWorkbook.Worksheets(Array("Tab name")).Copy is it possible for me to use a cell value instead of having to enter the worksheet name or read the Worksheet tab and use this value thanks kevin |
#2
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
kevcar40 wrote on 6/8/2011 :
Hi I am using the formula below to copy a worksheet, which is then pasted out to another workbook. ThisWorkbook.Worksheets(Array("Tab name")).Copy is it possible for me to use a cell value instead of having to enter the worksheet name or read the Worksheet tab and use this value thanks kevin If it's the active sheet: ThisWorkbook.ActiveSheet.Copy If several sheets: Group them first, then use... ActiveWindow.SelectedSheets.Copy OR possibly ThisWorkbook.Sheets(Array(sWksList)).Copy '//not tested A reusable function for grouping sheets: '''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''' ' GroupSheets() ' This procedure requires only the necessary amount of coding be used ' in the Caller. By default, it requires passing only the first arg. ' Use Example: GroupSheets "Sheet1,Sheet3" ' creates a group of only those sheets. ' To group all sheets in a workbook except those sheets: ' GroupSheets "Sheet1,Sheet3", False ' To group all sheets in a workbook pass an empty string: ' GroupSheets "", False ' You can pass the Wkb arg to specify any open workbook. ' (The Wkb doesn't need to be active for this purpose) '''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''' Public Sub GroupSheets(Sheetnames As String, _ Optional bInGroup As Boolean = True, _ Optional Wkb As Workbook) ' Groups sheets in Wkb based on whether Sheetnames ' are to be included or excluded in the grouping. ' Arg1 is a comma delimited string. (ie: "Sheet1,Sheet3") Dim Shts() As String, sz As String Dim i As Integer, Wks As Worksheet, bNameIsIn As Boolean If Wkb Is Nothing Then Set Wkb = ActiveWorkbook For Each Wks In Wkb.Worksheets bNameIsIn = (InStr(Sheetnames, Wks.name) 0) If bInGroup Then If bNameIsIn Then sz = Wks.name Else If bNameIsIn Then sz = "" Else sz = Wks.name End If If Not sz = "" Then '//build the array ReDim Preserve Shts(0 To i): Shts(i) = sz: i = i + 1 End If Next ActiveWorkbook.Worksheets(Shts).Select End Sub -- Garry Free usenet access at http://www.eternal-september.org ClassicVB Users Regroup! comp.lang.basic.visual.misc |
#3
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
GS formulated on Wednesday :
Next ActiveWorkbook.Worksheets(Shts).Select End Sub Oops! The above should read... Next Wkb.Worksheets(Shts).Select End Sub -- Garry Free usenet access at http://www.eternal-september.org ClassicVB Users Regroup! comp.lang.basic.visual.misc |
#4
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Since you're only copying a single sheet, you don't need the Array() portion:
ThisWorkbook.Worksheets("Tab name").Copy You could use something like this to get the value from a cell on a worksheet: ThisWorkbook.Worksheets(thisworkbook.worksheets("S omeSheet").range("A1").Value)).copy or to save a bit of typing: With thisworkbook .worksheets(.worksheets("somesheet").range("a1").v alue).copy end with On 06/08/2011 07:10, kevcar40 wrote: Hi I am using the formula below to copy a worksheet, which is then pasted out to another workbook. ThisWorkbook.Worksheets(Array("Tab name")).Copy is it possible for me to use a cell value instead of having to enter the worksheet name or read the Worksheet tab and use this value thanks kevin -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Complex conditional summing - array COUNT works, array SUM gives#VALUE | Excel Worksheet Functions | |||
Array formula: how to join 2 ranges together to form one array? | Excel Worksheet Functions | |||
Prevent cell/array references from changing when altering/moving thecell/array | Excel Discussion (Misc queries) | |||
meaning of : IF(Switch; Average(array A, array B); array A) | Excel Worksheet Functions | |||
combining cells and array from different sheets into an array to pass to IRR() | Excel Discussion (Misc queries) |