ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

[µo°Ý] VBA ¤¤­pºâ¼Æ­È°ÝÃD

¸ß°Ý¯x°}³]­p°ÝÃD

§Ú¼g¤F¤@­Ó 4*4 ªº¯x°}, ¯x°}­È·|¦³¤À¼Æ, ¦ý°õ¦æ«á < 0 ªº³¡¥÷³£Åã¥Ü 0
¦pªG¤~¯àÅý¥¦Åã¥Ü¤À¼Æ?

»yªk:
Dim myarray1(2 To 5, 2 To 5) As Integer

myarray1(2, 2) = 1
myarray1(2, 3) = 1
myarray1(2, 4) = 3
myarray1(2, 5) = 5

myarray1(3, 2) = 1
myarray1(3, 3) = 1
myarray1(3, 4) = 2
myarray1(3, 5) = 4

myarray1(4, 2) = 1 / 3
myarray1(4, 3) = 1 / 3
myarray1(4, 4) = 1
myarray1(4, 5) = 5

myarray1(5, 2) = 1 / 5
myarray1(5, 3) = 1 / 4
myarray1(5, 4) = 1 / 5
myarray1(5, 5) = 1

For i = 2 To 5
  For j = 2 To 5
    Cells(i, j).Value = myarray1(i, j)
    Next j
Next i

End Sub

TOP

1.±N©w¸q§ï¦¨ Dim myarray1(2 To 5, 2 To 5) As Single ´N¥i¥H
2.Àx¦s®æ ®æ¦¡§ï¦¨ ¤À¼Æ®æ¦¡

TOP

°ÝÃD¤w¸Ñ¨M   «D±`ÁÂÁ§A

TOP

[µo°Ý] VBA ¤¤­pºâ¼Æ­È°ÝÃD

§Ú³]­p¤F¤@­Ó 3*3 ªº¯x°}, ·Q°µ row ªº­¼ªk,
¨Ò¦p, myarray1(2,2) ªº 1 * myarray1(3, 2) = 1 *myarray1(4, 2) = 1 / 3
§Y 1*1*3

³o­Ó»yªk­n«ç»ò¼g?

Dim myarray1(2 To 4, 2 To 4) As Single

myarray1(2, 2) = 1
myarray1(2, 3) = 1
myarray1(2, 4) = 3

myarray1(3, 2) = 1
myarray1(3, 3) = 1
myarray1(3, 4) = 2

myarray1(4, 2) = 1 / 3
myarray1(4, 3) = 1 / 2
myarray1(4, 4) = 1


For i = 2 To 4
  For j = 2 To 4
    Cells(i, j).Value = myarray1(i, j)
    Next j
Next i

End Sub

¦^´_ 4# temple

¬O³o¼Ë¶Ü?
  1. Option Explicit
  2. Sub Ex()
  3.     Dim myarray1(2 To 4, 2 To 4) As Single
  4.     Dim i As Integer, j As Integer
  5.     i = UBound(myarray1, 1)
  6.     i = i - LBound(myarray1, 1) + 1 '²Ä¤@ºûªº¤¸¯À¼Æ
  7.     j = UBound(myarray1, 2)
  8.     j = j - LBound(myarray1, 2) + 1 '²Ä¤Gºûªº¤¸¯À¼Æ
  9.    
  10.     myarray1(2, 2) = 1
  11.     myarray1(2, 3) = 1
  12.     myarray1(2, 4) = 3
  13.    
  14.     myarray1(3, 2) = 1
  15.     myarray1(3, 3) = 1
  16.     myarray1(3, 4) = 2

  17.     myarray1(4, 2) = 1 / 3
  18.     myarray1(4, 3) = 1 / 2
  19.     myarray1(4, 4) = 1

  20.     With Range("C5")                '«ü©w·¡åJ®æ¦ì¸m
  21.         .Resize(i, j) = myarray1    'ÂX¥Rªº½d³ò«ü©w¬°myarray1ªº­È
  22.     End With
  23. End Sub
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¥ýÁÂÁ¶W¯Åª©¥Dªº«Øij, §Ú¬O·Q¦b¯x°}¤¤¦A¥[¤@­ÓÄæ¦ì, ¥i¥H¦Û°Ê°µ rowªº­pºâ, ¹³¤U­±¨º­Ó¯x°}¤@¼Ë
1.............1........3.........(1*1*3)
1.............1....... 2........(1*1*3)
1/3.....1/2.......1........(1/3*1/2*1)

TOP

¦^´_ 6# temple
¸Õ¸Õ¬Ý
  1. Option Explicit
  2. Sub Ex()
  3.     Dim myarray1(2 To 4, 2 To 4) As Single
  4.     Dim AR As Variant
  5.     Dim i As Integer, j As Integer
  6.    
  7.     myarray1(2, 2) = 10
  8.     myarray1(2, 3) = 10
  9.     myarray1(2, 4) = 3
  10.    
  11.     myarray1(3, 2) = 5
  12.     myarray1(3, 3) = 17
  13.     myarray1(3, 4) = 2

  14.     myarray1(4, 2) = 1 / 3
  15.     myarray1(4, 3) = 1 / 2
  16.     myarray1(4, 4) = 1
  17.    
  18.     AR = myarray1
  19.     ReDim Preserve AR(LBound(myarray1) To UBound(myarray1), LBound(myarray1, 2) To UBound(myarray1, 2) + 1)
  20.    
  21.     For i = LBound(AR) To UBound(AR)
  22.         AR(i, UBound(AR, 2)) = Application.Product(Application.WorksheetFunction.Index(myarray1, i - LBound(AR) + 1))
  23.     Next
  24.    
  25.     i = UBound(AR, 1)
  26.     i = i - LBound(AR, 1) + 1 '²Ä¤@ºûªº¤¸¯À¼Æ
  27.     j = UBound(AR, 2)
  28.     j = j - LBound(AR, 2) + 1 '²Ä¤Gºûªº¤¸¯À¼Æ
  29.    
  30.     With ActiveSheet.Range("C5")     '«ü©w·¡åJ®æ¦ì¸m
  31.         .Resize(i, j) = AR      'ÂX¥Rªº½d³ò«ü©w¬°Arªº­È
  32.     End With
  33. End Sub
½Æ»s¥N½X
1

µû¤À¤H¼Æ

·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

·Q¦A¸ß°Ý¶W¯Åª©¥D¡A­Y§Ú¦A¥[¤J¤@­ÓÄæ¦ì¡A±q 3*3 ÅÜ 4*4, À³¸Ó«ç»ò­×§ï»yªk¡H(¬Ý¤F¦n¤[, ¤£¤Ó¤F¸Ñ ReDim ³o¥y»yªk)

1.............1........3.......2........(1*1*3*2)
1.............1....... 2......1.........(1*1*3*1)
1/3.....1/2.......1.......3........(1/3*1/2*1*3)

TOP

¦^´_ 8# temple

ReDim ³¯­z¦¡¦bµ{§Ç¼h¦¸¤¤¥Î¨Ó­«·s°t¸m°ÊºA°}¦CÅܼƪºÀx¦sªÅ¶¡¡C
»yªk
ReDim [Preserve] varname(subscripts) [As type] [, varname(subscripts) [As type]] . . .
Preserve ¿ï¾Ü©Ê¤Þ¼Æ¡C·í§ïÅܭ즳°}¦C³Ì«á¤@ºûªº¤j¤p®É¡A¤´µM«O¦³­ì¨Óªº¸ê®ÆªºÃöÁä¦r¡C


  1. Option Explicit
  2. Sub EX()
  3.     Dim AR()
  4.     AR = [A1:F2].Value '-> AR(1 To 2, 1 To 6)
  5.    
  6.     ReDim Preserve AR(1 To 2, 1 To 7)
  7. End Sub
½Æ»s¥N½X







·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

ÁÂÁ§A --- §Ú·|¦A½m²ß¬Ý¬Ý, ¦³°ÝÃD¦A³Â·Ð§AÅo~~

TOP

        ÀR«ä¦Û¦b : ­n¤ñ½Ö§ó¨ü½Ö¡D¤£­n¤ñ½Ö§ó©È½Ö¡C
ªð¦^¦Cªí ¤W¤@¥DÃD