PC Review


Reply
Thread Tools Rate Thread

Creating and transposing a multiarray

 
 
Brad
Guest
Posts: n/a
 
      24th Mar 2009
I have some code that will filter a table in excel on two factors, sum the
visible rows in a particular column, store the sums in a 2 dimensional array
and transpose the array to another workbook. I believe the array is being
created properly; however, it does not transpose correct. Here is the code.
Any help would be appreciated.

Dim iCalWeek As Integer ' Variable for calendar week number
Dim iRow As Integer ' Row variable for array
Dim iCol As Integer ' Column variable for array
Dim wsTop8DC As Worksheet ' Variable for Top 8 Worksheet
Dim tblTop8DC As ListObject ' Variable for Top 8 Defect Count
' 2 dim array to hold Loop 4 count on 8 issues for past 7 calendar weeks
Dim iLoop4Totals(1 To 7, 1 To 8) As Integer

' Set iCalWeek to 8 weeks before current week
iCalWeek = WorksheetFunction.WeekNum(Date) - 8
Set wsTop8DC = Workbooks("Tables").Sheets("Top8DefectCount")
Set tblTop8DC = wsTop8DC.ListObjects("tblTop8DC")

For iRow = 1 To 7
With tblTop8DC
.Range.AutoFilter Field:=7 ' Clear Filter
' Filter table based on calendar week
.Range.AutoFilter Field:=7, Criteria1:=(iCalWeek + iRow)
End With

For iCol = 1 To 8
With tblTop8DC
.Range.AutoFilter Field:=3 ' Clear Filter
' Filter table based on issue number
.Range.AutoFilter Field:=3, Criteria1:=iCol
End With
With wsTop8DC
' Set array value to sum of issues occurance
iLoop4Totals(iRow, iCol) = _

WorksheetFunction.Sum(.Range("F:F").SpecialCells(xlCellTypeVisible))
End With
Next
Next
' Transpose Array
With Workbooks("Top8Slides").Sheets("Data")
.Range("B4:I10") = WorksheetFunction.Transpose(iLoop4Totals)
End With
 
Reply With Quote
 
 
 
 
KC
Guest
Posts: n/a
 
      24th Mar 2009
May be
..range("B4:H11") = WorksheetFunction.Transpose(iLoop4Totals)

"Brad" <(E-Mail Removed)> wrote in message
news:FCD72BDF-2326-4E99-95F7-(E-Mail Removed)...
>I have some code that will filter a table in excel on two factors, sum the
> visible rows in a particular column, store the sums in a 2 dimensional
> array
> and transpose the array to another workbook. I believe the array is being
> created properly; however, it does not transpose correct. Here is the
> code.
> Any help would be appreciated.
>
> Dim iCalWeek As Integer ' Variable for calendar week number
> Dim iRow As Integer ' Row variable for array
> Dim iCol As Integer ' Column variable for array
> Dim wsTop8DC As Worksheet ' Variable for Top 8 Worksheet
> Dim tblTop8DC As ListObject ' Variable for Top 8 Defect Count
> ' 2 dim array to hold Loop 4 count on 8 issues for past 7 calendar weeks
> Dim iLoop4Totals(1 To 7, 1 To 8) As Integer
>
> ' Set iCalWeek to 8 weeks before current week
> iCalWeek = WorksheetFunction.WeekNum(Date) - 8
> Set wsTop8DC = Workbooks("Tables").Sheets("Top8DefectCount")
> Set tblTop8DC = wsTop8DC.ListObjects("tblTop8DC")
>
> For iRow = 1 To 7
> With tblTop8DC
> .Range.AutoFilter Field:=7 ' Clear Filter
> ' Filter table based on calendar week
> .Range.AutoFilter Field:=7, Criteria1:=(iCalWeek + iRow)
> End With
>
> For iCol = 1 To 8
> With tblTop8DC
> .Range.AutoFilter Field:=3 ' Clear Filter
> ' Filter table based on issue number
> .Range.AutoFilter Field:=3, Criteria1:=iCol
> End With
> With wsTop8DC
> ' Set array value to sum of issues occurance
> iLoop4Totals(iRow, iCol) = _
>
> WorksheetFunction.Sum(.Range("F:F").SpecialCells(xlCellTypeVisible))
> End With
> Next
> Next
> ' Transpose Array
> With Workbooks("Top8Slides").Sheets("Data")
> .Range("B4:I10") = WorksheetFunction.Transpose(iLoop4Totals)
> End With



 
Reply With Quote
 
Jacob Skaria
Guest
Posts: n/a
 
      24th Mar 2009
Dear Brad

I did not test this but after transposing the range should be B4:H11 instead
of B4:I10. Please try and feedback.

..Range("B4:H11") = WorksheetFunction.Transpose(iLoop4Totals)

If this post helps click Yes
--------------
Jacob Skaria

"Brad" wrote:

> I have some code that will filter a table in excel on two factors, sum the
> visible rows in a particular column, store the sums in a 2 dimensional array
> and transpose the array to another workbook. I believe the array is being
> created properly; however, it does not transpose correct. Here is the code.
> Any help would be appreciated.
>
> Dim iCalWeek As Integer ' Variable for calendar week number
> Dim iRow As Integer ' Row variable for array
> Dim iCol As Integer ' Column variable for array
> Dim wsTop8DC As Worksheet ' Variable for Top 8 Worksheet
> Dim tblTop8DC As ListObject ' Variable for Top 8 Defect Count
> ' 2 dim array to hold Loop 4 count on 8 issues for past 7 calendar weeks
> Dim iLoop4Totals(1 To 7, 1 To 8) As Integer
>
> ' Set iCalWeek to 8 weeks before current week
> iCalWeek = WorksheetFunction.WeekNum(Date) - 8
> Set wsTop8DC = Workbooks("Tables").Sheets("Top8DefectCount")
> Set tblTop8DC = wsTop8DC.ListObjects("tblTop8DC")
>
> For iRow = 1 To 7
> With tblTop8DC
> .Range.AutoFilter Field:=7 ' Clear Filter
> ' Filter table based on calendar week
> .Range.AutoFilter Field:=7, Criteria1:=(iCalWeek + iRow)
> End With
>
> For iCol = 1 To 8
> With tblTop8DC
> .Range.AutoFilter Field:=3 ' Clear Filter
> ' Filter table based on issue number
> .Range.AutoFilter Field:=3, Criteria1:=iCol
> End With
> With wsTop8DC
> ' Set array value to sum of issues occurance
> iLoop4Totals(iRow, iCol) = _
>
> WorksheetFunction.Sum(.Range("F:F").SpecialCells(xlCellTypeVisible))
> End With
> Next
> Next
> ' Transpose Array
> With Workbooks("Top8Slides").Sheets("Data")
> .Range("B4:I10") = WorksheetFunction.Transpose(iLoop4Totals)
> End With

 
Reply With Quote
 
Brad
Guest
Posts: n/a
 
      24th Mar 2009
Actually it was
..Range("B4:H10) = WorksheetFunction.Transpose(iLoop4Totals)

With H11 I got an extra row of 0's.

Thanks so much for the help. Couldn't have figured it out without it.

"Jacob Skaria" wrote:

> Dear Brad
>
> I did not test this but after transposing the range should be B4:H11 instead
> of B4:I10. Please try and feedback.
>
> .Range("B4:H11") = WorksheetFunction.Transpose(iLoop4Totals)
>
> If this post helps click Yes
> --------------
> Jacob Skaria
>
> "Brad" wrote:
>
> > I have some code that will filter a table in excel on two factors, sum the
> > visible rows in a particular column, store the sums in a 2 dimensional array
> > and transpose the array to another workbook. I believe the array is being
> > created properly; however, it does not transpose correct. Here is the code.
> > Any help would be appreciated.
> >
> > Dim iCalWeek As Integer ' Variable for calendar week number
> > Dim iRow As Integer ' Row variable for array
> > Dim iCol As Integer ' Column variable for array
> > Dim wsTop8DC As Worksheet ' Variable for Top 8 Worksheet
> > Dim tblTop8DC As ListObject ' Variable for Top 8 Defect Count
> > ' 2 dim array to hold Loop 4 count on 8 issues for past 7 calendar weeks
> > Dim iLoop4Totals(1 To 7, 1 To 8) As Integer
> >
> > ' Set iCalWeek to 8 weeks before current week
> > iCalWeek = WorksheetFunction.WeekNum(Date) - 8
> > Set wsTop8DC = Workbooks("Tables").Sheets("Top8DefectCount")
> > Set tblTop8DC = wsTop8DC.ListObjects("tblTop8DC")
> >
> > For iRow = 1 To 7
> > With tblTop8DC
> > .Range.AutoFilter Field:=7 ' Clear Filter
> > ' Filter table based on calendar week
> > .Range.AutoFilter Field:=7, Criteria1:=(iCalWeek + iRow)
> > End With
> >
> > For iCol = 1 To 8
> > With tblTop8DC
> > .Range.AutoFilter Field:=3 ' Clear Filter
> > ' Filter table based on issue number
> > .Range.AutoFilter Field:=3, Criteria1:=iCol
> > End With
> > With wsTop8DC
> > ' Set array value to sum of issues occurance
> > iLoop4Totals(iRow, iCol) = _
> >
> > WorksheetFunction.Sum(.Range("F:F").SpecialCells(xlCellTypeVisible))
> > End With
> > Next
> > Next
> > ' Transpose Array
> > With Workbooks("Top8Slides").Sheets("Data")
> > .Range("B4:I10") = WorksheetFunction.Transpose(iLoop4Totals)
> > End With

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
redim multiarray ranswert Microsoft Excel Programming 3 24th Mar 2008 10:30 PM
TRANSPOSING GARY Microsoft Excel Misc 1 17th Mar 2006 11:09 AM
transposing and creating new rows =?Utf-8?B?a3JvdmU=?= Microsoft Excel Programming 4 21st Oct 2005 07:51 PM
Transposing... Dave Microsoft Excel Worksheet Functions 1 25th May 2004 07:15 AM
Transposing s boak Microsoft Excel Worksheet Functions 0 11th Mar 2004 01:19 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:50 AM.