Hi,
I have been trying to get this done for literally 12hrs. I am trying to learn how to use Arrays. I figured I would start with something small like a range & use the values in that range to delete some workSheets. lol I crashed myExcelApp.GoodTimes
Onto the matter @ hand would someone please be so kind as to help me out with either/or, but both would be great.
#1 Here I have some code that creates an Array from a range.
Array:
I would like to use the above Array to compare against SheetName in the CaseStatement below:![]()
Sub SimpleArray() 'You can use code like the following to loop through the array of the worksheet values: 'http://www.cpearson.com/excel/ArraysAndRanges.aspx Dim Arr() As Variant Arr = Range("A20:A100") Dim R As Long Dim C As Long For R = 1 To UBound(Arr, 1) ' First array dimension is rows. For C = 1 To UBound(Arr, 2) ' Second array dimension is columns. Debug.Print Arr(R, C) Next C Next R End Sub
#2 I would also like to know how I could wrap all of a Workbooks Worksheets in an Array, so that I could use the above CaseStatment to delete matching sheets of another workbook.![]()
Sub iCase_AWK_DelShs() 'http://www.vbaexpress.com/forum/showthread.php?14285-Solved-delete-all-sheets-not-in-array%281-to-4%29 '+----------- Dim sht As Worksheet Application.DisplayAlerts = False For Each sht In ActiveWorkbook.Worksheets Select Case sht.Name Case Is = "SheetNamesArray" '<---- I so... want this to be my Array[Range] Debug.Print sht.Name '.Delete Case Else 'Do nothing End Select Next sht Application.DisplayAlerts = True '+----------- End Sub
I had some broilerPlate I was playing with a few hours ago before I crashedExcel; I cant find it but I did find something else I think I might be able to do that with.
As always any help is greatly appreciated. TIA![]()
Sub iArry() Dim SNarray, i ReDim SNarray(1 To Sheets.Count) For i = 1 To Sheets.Count SNarray(i) = ActiveWorkbook.Sheets(i).Name Debug.Print SNarray(i) Next End Sub











LinkBack URL
About LinkBacks
GoodTimes
Register To Reply




Bookmarks