Home |
Search |
Today's Posts |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I'm notr sure what you are trying to do but I have written macros that merge
worksheets togeter where the rows and columns are different. I don't use arrays to accomplish this task. Instead I use the find function. Below is a summary of the code I use. This code is not tested. I just used to show an example of what I usually do. the coe need to be adjusted depending on the number of sheets yo are adding to the mater worksheet. Using VBA functions like the FIND Method is sometimes quicker than working with arrays in VBA. sorting and searching using VBA code is usally slower that using stand methods and function methods that microsoft optimized. The optimized code (like FIND) has been run through compilers that are designed to make the code run quickly. The VBA code isn't optimized the same way which makes the code run slower. 1) Start with blank worksheet which I use as a master worksheet. then repeat this process for each worksheet/workbook I want to add to the master sheet. 2) Each worksheet I add has an ID row in column A and a set of headers in row 1. 3) I use two for loop to span each new worksheet I add to the master NewRow = 2 NewCol = 2 For ColCount = 2 to LastColumn ColumnHeader = cells(1,Colcount) 'check if header exists in master sheet set c = MasterSht.Rows(1).find(what:=ColHeader) if c is nothing then AddCol = NewCol NewCol = Newcol + 1 else AddCol = c.column end if for RowCount = 2 to Lastrow RowHeader = Range("A" & RowCount) 'check if header exists in master sheet set c = MasterSht.Columns("A").find(what:=RowHeader) if c is nothing then AddRow = NewRow NewRow = NewRow + 1 else AddRow = c.column end if MasterSht.Cells(AddRow, AddCol) = Range(RowCount,ColCount) next RowCount NextColCount "needhelp" wrote: thanks to Par Jessen I can now populate my arrays (previous question)... however i have another issue with another array. The array is dynamic (single dimension). Each array element is the count of cells e.g. numpkfrows(1) = 216 numpkfrows(2) = 219 numpkfrows(3) = 216 ....numpkfrows(n) i now need to determine if all of the values of the array elements are the same (so in the above example I would want an error thrown). (hope this makes sense) What would be the easiest way to compare all of the elements within the array? Cheers Julie |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
running sum needed with #N/A in array | Excel Discussion (Misc queries) | |||
array help needed | Excel Programming | |||
Possible Array Solution Needed? | Excel Discussion (Misc queries) | |||
Maybe an array is needed? | Excel Worksheet Functions | |||
Array Help Needed | Excel Programming |