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

[µo°Ý] VBA_½Ð²¤Æµ{¦¡½X¡CÁÂÁÂ!

VBA_°õ¦æ¶¥¬q¿ù»~ "1004" ªº­×¥¿¡C

¥»©«³Ì«á¥Ñ Airman ©ó 2015-11-21 11:09 ½s¿è

°õ¦æ¨ì¦C9¼u¥X¡J
°õ¦æ¶¥¬q¿ù»~  "1004"
Class Range ªº Select¤èªk¥¢±Ñ


½Ð°Ý¡J­n¦p¦ó­×¥¿?  ÁÂÁÂ!
Private Sub CommandButton1_Click()
Dim J%, K%, tx%, ty%, tz%, b

With Sheets(2)
      Sheets(1).Range("J7", "P" & Sheets(2).[R6] + 5).Copy .[J7]
      tx = .[R7].End(xlDown).Row
      ty = .[T5].End(xlToRight).Column
      For tz = 20 To ty
      .Range("T7:T" & tx).Select
      For Each b In Selection
      If b <> "" Then
  For J = 10 To 16
    For K = 10 To 16
      If .Range("R" & b.Row) + 1 = .[T5] Then
       If .Range("R" & b.Row) - .[T3] * 2 > 6 Then
         If .Cells(.[T5] + 6, J) = .[R5] Then
         If .Cells(.[T5] - 6, J) = .[R5] Then
         If .Cells(.[T5] + 6, J) = .[R5] Then
          With .Cells(.[T5] + 6, J): .Interior.ColorIndex = 4: .Font.ColorIndex = 3: .Font.FontStyle = "²ÊÅé": End With
          With .Cells(.[T5] - .[T3] + 6, J): .Interior.ColorIndex = 45: .Font.ColorIndex = 3: .Font.FontStyle = "²ÊÅé": End With
          With .Cells(.[T5] - .[T3] * 2 + 6, J): .Interior.ColorIndex = 8: .Font.ColorIndex = 3: .Font.FontStyle = "²ÊÅé": End With         
         End If
         End If
         End If
       End If
      End If
    Next K
  Next J
      End If
      Next b
      Next tz
End With
[A1].Select
End Sub

TOP

¾Þ§@µ{¦¡®É, Sheets(2)¤£¬O·í«e¤u§@ªí, ¶·¥ý¸õÂà:
With Sheets(2)
        .Select
      .Range("T7:T" & tx).Select ³o¦æ¤~¤£·|¿ù»~

¤£¹L, ¤u§@ªí¸õÂà­Y«D¥²­n, ¥i:
      For Each b In .Range("T7:T" & tx)  '¤£¥ÎSelection, ¤W¨â¦æ¥i§R¥h

TOP

¥»©«³Ì«á¥Ñ Airman ©ó 2015-11-21 14:17 ½s¿è

[¦^´_ 2# ­ã´£³¡ªL
TEST_1.rar (60.04 KB)
­ã¤j:
·PÁ«ü¾É~
¨Ì·Ó¶Q¸Ñ­×¥¿«á¡AÅܦ¨·|¤¤Â_¦b[A1].Select
±N¨äÂI±¼«á¡A§Y¥i§¹¦¨°õ¦æ¡C

¦ý°õ¦æ§¹²¦«á¡A¦C19~¦C21ªºT5,T5-T3,T5-T3*2¤§R5ÃC¦â¼Ð¥Ü§¹¥þ¨S¦³¥X¨Ó~¤£ª¾¤p§ÌÁÙ¦³¨º¸Ì¼g¿ù¤F:funk: ~
·q½Ð±z¦A´f¤©½ç¥¿~·P®¦!

PS:¥t¦A½Ð±Ð¡J¦C33 [A1].Select¦pªG¤£ÂI±¼¡A¤S­n¦p¦ó­×¥¿? ÁÂÁ±z!

TEST_1.rar (60.04 KB)

TOP

¦^´_ 3# Airman


    .[A1].Activate
End With

[A1]¬OSheets(2)ªº, ­n©ñ¦bWith¸Ì­±!

TOP

¥»©«³Ì«á¥Ñ Airman ©ó 2015-11-21 18:32 ½s¿è

¦^´_ 4# ­ã´£³¡ªL

­ã¤j:
[A1].Select§ï¬° [A1].Activate
¥i§¹¦¨°õ¦æ~OK¤F~ÁÂÁ±z:D

¦ý¦C19~¦C21ªºT5,T5-T3,T5-T3*2¤§R5ÃC¦âÁÙ¬O§¹¥þ¨S¦³¼Ð¥Ü¥X¨Ó~¤£ª¾¤p§ÌÁÙ¦³¨º¸Ì¼g¿ù¤F:L
T5=91´Á¡FT5-T3=82´Á¡FT5-T3*2=73´Á
R5=11  

·q½Ð±z¦A´f¤©½ç¥¿~·P®¦:lol

TOP

¥»©«³Ì«á¥Ñ ­ã´£³¡ªL ©ó 2015-11-21 20:31 ½s¿è

¦^´_ 5# Airman


If .Cells(.[T5] + 6, J) = .[R5] Then
If .Cells(.[T5] - .[T3] + 6, J) = .[R5] Then
If .Cells(.[T5] - .[T3] * 2 + 6, J) = .[R5] Then
¡ã¡ã
¡ã¡ã
¡ã¡ã
End If
End If
End If

¬Ý¤£À´¬°¦ó³o¼Ë¼g¡A¶·¤T­Óif³£¦¨¥ß¡A¤~¶i¦æ¤§¤ºªº¾Þ§@¡A
¬O§_À³¦U¦Û¤À¬q¡G
If .Cells(.[T5] + 6, J) = .[R5] Then
¡ã¡ã
End If
If .Cells(.[T5] - .[T3] + 6, J) = .[R5] Then
¡ã¡ã
End If
If .Cells(.[T5] - .[T3] * 2 + 6, J) = .[R5] Then
¡ã¡ã
End If

TOP

¦^´_ 6# ­ã´£³¡ªL
­ã¤j:
If .Cells(.[T5] + 6, J) = .[R5] Then
¡ã¡ã
End If
³æ¿W±ø¥ó§Y¼Ð¥ÜÃC¦â¬O¨S¦³°ÝÃD¡C

¦ý¤p§Ìªº·N«ä¡A¬O·Q­n·íT5,T5-T3,T5-T3*2µ¥¤T­Ó´Á¼Æ(91,82,73)³£¦³Åã¥ÜR5­È(=11)~
3­Ó±ø¥ó¦P®É¦¨¥ß¤~¼Ð¥ÜÃC¦â~©Ò¥H±N3­ÓIf...±ø¥ó...ThenÂ\«e­±~¦ýÅãµM¬O¤p§Ìªº»yªk¿ù»~¡A¤~·|µ{¦¡°õ¦æ§¹²¦«oµLÃC¦â¼Ð¥Ü

½Ð°Ý:
·íT5,T5-T3,T5-T3*2µ¥¤T­Ó´Á¼Æ(91,82,73)¦P®É³£¦³Åã¥ÜR5­È(=11)®É~
«h3­Ó´Á¼ÆÅã¥ÜR5­ÈªºÀx¦s®æ¼Ð¥ÜÃC¦â¤§¥¿½T»yªk¡AÀ³¸Ó¦p¦ó¼g?

·q½Ð±z¦A¦¸´f¤©½ç¥¿~·P®¦

TOP

¦^´_ 5# Airman
­ã¤j:
¦]±zªº´£¥Ü~ª¾¹D¿ù»~ªºµ{¦¡½X¦b¦ó³B~
­è­è¸Õ±Nµ{¦¡½X§ï¬°~
         If .Cells(.[T5] + 6, I) = .[R5] Then
         If .Cells(.[T5] - .[T3] + 6, J) = .[R5] Then
         If .Cells(.[T5] - .[T3] * 2 + 6, K) = .[R5] Then
           With .Cells(.[T5] + 6, I): .Interior.ColorIndex = 4: .Font.ColorIndex = 3: .Font.FontStyle = "²ÊÅé": End With
           With .Cells(.[T5] - .[T3] + 6, J): .Interior.ColorIndex = 45: .Font.ColorIndex = 3: .Font.FontStyle = "²ÊÅé": End With
           With .Cells(.[T5] - .[T3] * 2 + 6, K): .Interior.ColorIndex = 8: .Font.ColorIndex = 3: .Font.FontStyle = "²ÊÅé": End With
         End If
         End If
         End If
§Y¥i§¹¦¨ÃC¦â¼Ð¥Ü¡C

¦ý½Ð°Ý:¥u¯à³o¼Ë¼g¶Ü?
·q½Ð±z¦A´f¤©½ç¥¿~·P®¦

PS:¦]¬°«áÄòÁÙ¦³µ{¦¡­n±µÄò¡AÅܼưZ¤£¬O¦hªº¥O¤H¼º¶Ã¡C

TOP

¦^´_ 8# Airman
¸Õ¸Õ¬Ý
  1. Option Explicit
  2. Sub Ex()
  3.     Dim Rng As Range, E As Variant, C As Variant
  4.     With Sheets(2)
  5.         Sheets(1).Range("J7", "P" & Sheets(2).[R6] + 5).Copy .[J7]
  6.         Set Rng = .[J7].Resize(.[J7].End(xlDown).Row, 7)
  7.         For Each E In Array(.[T5], .[T5] - .[T3], .[T5] - .[T3] * 2)
  8.                             '.T5,T5-T3,T5-T3*2 '91,82,73
  9.             C = Application.Match(.[R5], Rng.Rows(E), 0) '§ä¨ì¶Ç¦^¼Æ¦r
  10.             If IsNumeric(C) Then
  11.                 With Rng.Rows(E).Cells(C)
  12.                     .Interior.ColorIndex = 4
  13.                     .Font.ColorIndex = 3
  14.                     .Font.FontStyle = "²ÊÅé"
  15.                 End With
  16.             End If
  17.         Next
  18.     End With
  19. End Sub
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¦^´_ 9# GBKEE
GBKEE¶W¯Åª©¤j:
·PÁ±zªº¤£§[½ç±Ð»P«ü¾É~´ú¸ÕOK¤F~§¹¥þ²Å¦X»Ý¨D~·P®¦

PS:µ{¦¡½X²¤Æ³\¦h~¤p§Ì±oºCºC®ø¤Æ¾Ç²ß

TOP

        ÀR«ä¦Û¦b : ¤@­Ó¯Ê¤fªºªM¤l¡A¦pªG´«¤@­Ó¨¤«×¬Ý¥¦¡A¥¦¤´µM¬O¶êªº¡C
ªð¦^¦Cªí ¤W¤@¥DÃD