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

[µo°Ý] ÅܼƳ]©w

[µo°Ý] ÅܼƳ]©w

½Ð§â°}¦C¤¤ªº¹ïÀ³¦ì¸m­È³]µ¹ÅܼơAVBA¦p¦ó°µ¡AÁÂÁÂ
  1. Option Base 1
  2. Option Explicit

  3. Sub Test()

  4.     '©w¸qÅܼÆ
  5.     Dim Qref%, kWref%, COPref%, Qev_ref%, Qcd_ref%, Tchws%, Tchwr%, Tcws%, Tcwr%
  6.     Dim a0%, a1%, a2%, a3%, a4%, a5%
  7.     Dim ar
  8.    
  9.     'ÅܼƦWºÙ°}¦C,   »¡©ú: ¦WºÙ¦b°}¦C¤¤ªº¦ì¸m¬O·|Åܪº
  10.     ar = Array("Qref", "kWref", "COPref", "Qev_ref", "Qcd_ref", "Tchws", "Tchwr", "Tcws", "Tcwr", _
  11.                 "a0", "a1", "a2", "a3", "a4", "a5")
  12.    
  13.     '§âÅܼƦWºÙ¦b°}¦C¤¤ªº¦ì¸m³]µ¹ÅܼÆ
  14.    
  15.     '(¦p¦ó¼gVBA¥i¥H±o¨ì´Á±æµ²ªG)'?
  16.     'Qref = 1
  17.     'kWref = 2
  18.     'COPref = 3
  19.     'Qev_ref = 4
  20.     'Qcd_ref = 5
  21.    
  22.     '   .
  23.     '   .
  24.     '   .
  25.     'a5 = 15
  26.    
  27.    
  28. End Sub
½Æ»s¥N½X

¥»©«³Ì«á¥Ñ stillfish00 ©ó 2016-3-7 15:25 ½s¿è

¦^´_ 1# Scott090
³o¼Ë?
Qref = Application.Match("Qref", ar, 0)
kWref = Application.Match("kWref", ar, 0)
ªí¹F¤£²M¡BÃD·N¤£©ú½T¡B¨SªþÀɮ׮榡¡B¨S¦³°Q½×°ÝÃDªººA«×~~~~~~¥H¤W·R²ö¯à§U¡C

TOP

¦^´_ 2# stillfish00


    ÁÂÁ¤j¤jªº¸Ñ´b¡Aµª®×¥¿¬O©Ò­nªº¡A«D±`·P®¦

¦A½Ð±Ð¡A
°²¦p¨Æ¥ý¨SÅܼƳ]©w¡A¬O§_¯à±q¦WºÙ°}¦C¤¤¤ÀÂ÷¥X ¨Ï¦¨¦U­ÓÅܼƨýá¤_¦b°}¦C¤¤ªº¦ì¸m­È?

TOP

¥»©«³Ì«á¥Ñ stillfish00 ©ó 2016-3-7 19:02 ½s¿è

¦^´_ 3# Scott090
¨S¿ìªk§a , °£«D¥þ¥Îcode¼gcode?
¬O»¡§A³o¼ËÅܼƪº¦WºÙ©ñ¦bArray¦³Ô£¦n³B¶Ü¡A©_©Çªº¥Îªk¡C
ªí¹F¤£²M¡BÃD·N¤£©ú½T¡B¨SªþÀɮ׮榡¡B¨S¦³°Q½×°ÝÃDªººA«×~~~~~~¥H¤W·R²ö¯à§U¡C

TOP

¦^´_ 4# stillfish00

«Dµ²ºc¤Æ©Ê¸ê®ÆªíÄæ¦ì¦h¡A°µ­pºâªºµ{¦¡©ö¥¢¥h¥iŪ©Ê¦Ó²V¶Ã¡F
¨Ò¦p:
       AR(i,j) ªº j ¥NªíÄæ¦ì¡AÄæ¦ì¦h¤F ¡Aj ¥u¬O¤@­Ó¼Æ¦r·§©À¡A¨S¦³¦Wµü·N¸q¡F·íµM¡A¼Æ¦r¥Î¨Ó°µ°j°é«Ü­«­n
       Cells(i,"B").offset(,j) ¤@¼Ëªº·N«ä

°²¦p¯à¥ÎÄæ¦ì¦WºÙ·íÅÜ¼Æ j¡A «h¬O¡G
     AR(i,Äæ¦ì¦WºÙ)
     cells(i,"B").offset(,Äæ¦ì¦WºÙ)

¥H¤W½Ð±Ð ¤j¤j  ¦³¨S¦³¨ä¥Lªº¸Ñªk

ÁÂÁÂ

TOP

¦^´_ 1# Scott090
  1. Option Base 1
  2. Option Explicit

  3. Sub Test1()

  4. '©w¸qÅܼÆ
  5.     Dim Qref%, kWref%, COPref%, Qev_ref%, Qcd_ref%, Tchws%, Tchwr%, Tcws%, Tcwr%
  6.     Dim a0%, a1%, a2%, a3%, a4%, a5%
  7.     Dim ar, x
  8.     Dim D As Object
  9.     Set D = CreateObject("Scripting.Dictionary")

  10.     'ÅܼƦWºÙ°}¦C,   »¡©ú: ¦WºÙ¦b°}¦C¤¤ªº¦ì¸m¬O·|Åܪº
  11.     ar = Array("Qref", "kWref", "COPref", "Qev_ref", "Qcd_ref", "Tchws", "Tchwr", "Tcws", "Tcwr") ', "a0", "a1", "a2", "a3", "a4", "a5")

  12.     '§âÅܼƦWºÙ¦b°}¦C¤¤ªº¦ì¸m³]µ¹ÅܼÆ

  13.     '(¦p¦ó¼gVBA¥i¥H±o¨ì´Á±æµ²ªG)'?
  14.     'Qref = 1
  15.     'kWref = 2
  16.     'COPref = 3
  17.     'Qev_ref = 4
  18.     'Qcd_ref = 5

  19.     '   .
  20.     '   .
  21.     '   .
  22.     'a5 = 15
  23.     For Each x In ar
  24.         D(x) = Application.Match(x, ar, 0)
  25.     Next

  26.     [E1:F1].Resize(D.Count) = Application.Transpose(Array(D.keys, D.items))
  27.    
  28.     For Each x In D.keys
  29.         Debug.Print x, D(x)
  30.     Next
  31. End Sub
½Æ»s¥N½X
{...} ªí¥Ü»Ý­n¥Î CTRL+SHIFT+ENTER ¤TÁä¿é¤J¤½¦¡

TOP

¥»©«³Ì«á¥Ñ stillfish00 ©ó 2016-3-8 09:34 ½s¿è

¦^´_ 5# Scott090
³B²z¸ê®ÆÄæ¦ì¼ÐÃD¡A¦pªG»Ý­n §Ú¤]¬O±ÄÃþ¦üMLª©¥Dªº°µªk
«Ø¥ß¤@­Ó¦r¨å¨Ó¹ïÀ³ : ¦WºÙ -> Ä渹
³o¼Ë§A´N¯à¹³³o¼Ë¥h¨Ï¥Î : Cells(i,"B").offset(,D("Qref"))
¤£¥Î«Å§i Qref ÅܼÆ

·íµM¡A³q±`¸ê®ÆÄæ¦ì³£¬O©T©w¦ì¸m®É¡Aª½±µ¥ÎConst©w±`¼Æ´N¦n¡C
ªí¹F¤£²M¡BÃD·N¤£©ú½T¡B¨SªþÀɮ׮榡¡B¨S¦³°Q½×°ÝÃDªººA«×~~~~~~¥H¤W·R²ö¯à§U¡C

TOP

¦^´_ 6# ML089


    ÁÂÁ¤j¤jªº¦^À³
©êºp¡A§Ú¨S§â°ÝÃD´y­z²M·¡

°ÝÃDªº¥Ø¼Ð¬O­n ½á­È µ¹ ÅܼơA¤£¥u¬O¦r¦ê¦b°}¦C¤¤ªº¦ì¸m
¨Ò¦p¡G
          Qref =1¡A¦]¬°¦r¦ê "Qref" ¦b °}¦Cªº¦ì¸m ¬O 1
          Qev_ref = 4, ¦]¬°¦r¦ê "Qev_ref" ¦b°}¦Cªº¦ì¸m¬O 4

TOP

¦^´_ 7# stillfish00


¤§©Ò¥Hµo·Q­n¥H°ÊºAªº¤è¦¡³B²z¡A
    ´N¬O¦]¬°Äæ¦ì«Ü¦h¥B¦ì¸m·|ÅÜ¡Fª½±µ¥Î Const ·|©Ô±o«Üªø¡A¸ê®Æ¦ì¸mÅܰʮɤ]¤£©ö§ó§ï

´£Ä³¥Î ML ª©¥Dªº¦r¨åªk D("Qref") À³¥i¦æ

´ú¸Õ«á¦A³ø§i

ÁÂÁÂ

TOP

¦^´_ 9# Scott090
¸Õ¸Õ¬Ý
  1. Option Base 1
  2. Option Explicit
  3. Sub Test()
  4.     '©w¸qÅܼÆ
  5.     '  Dim Qref%, kWref%, COPref%, Qev_ref%, Qcd_ref%, Tchws%, Tchwr%, Tcws%, Tcwr%
  6.     '  Dim a0%, a1%, a2%, a3%, a4%, a5%
  7.     Dim ar, i As Integer
  8.    
  9.     'ÅܼƦWºÙ°}¦C,   »¡©ú: ¦WºÙ¦b°}¦C¤¤ªº¦ì¸m¬O·|Åܪº
  10.     ar = Array("Qref", "kWref", "COPref", "Qev_ref", "Qcd_ref", "Tchws", "Tchwr", "Tcws", "Tcwr", _
  11.                 "_a0", "_a1", "_a2", "_a3", "_a4", "_a5")  '
  12.     For i = 1 To UBound(ar)
  13.         ActiveSheet.Names.Add ar(i), i     '¦b§@¥Î¤¤¤u§@ªí¤W©w¸q¦WºÙ,µ¹­È
  14.     Next
  15.     MsgBox Cells(i, "B").Offset(, [Qref]).Address
  16. End Sub
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

        ÀR«ä¦Û¦b : §g¤l¥ß«í§Ó¡A¤p¤H«í¥ß§Ó¡C
ªð¦^¦Cªí ¤W¤@¥DÃD