2014-11-23 3 views
1

내 워크 시트의 모양을 반복하여 드롭 다운인지 확인한 다음 특정 드롭 다운이 특정 행에있는 경우 확인하고 싶습니다. 워크 시트에는 많은 확인란과 드롭 다운이 있습니다. 다음,다양한 셰이프가 포함 된 워크 시트에서 셰이프 유형을 어떻게 결정합니까?

ActiveSheet.CheckBoxes.Add(Range(chkbxAddress).Left, Range(chkbxAddress).Top, Range(chkbxAddress).Width, Range(chkbxAddress).Height).Select 
With Selection 
    .Caption = "" 
    .Value = xlOff 
    .LinkedCell = AnsPositionRng.Offset(0, -4).Address 
    .Display3DShading = True 
End With 

범위의 특정 셀이 '참'이 포함 된 경우 :

wsBank.DropDowns.Add(Range(AnsPositionAddress).Left, Range(AnsPositionAddress).Top, Range(AnsPositionAddress).Width, Range(AnsPositionAddress).Height).Select 
With Selection 
    '.ListFillRange = AnsPositionRng.Offset(0, 1) 
    '.LinkedCell = AnsPositionRng.Offset(0, 1) 
    .DropDownLines = 4 
    .Display3DShading = False 
    .Name = "QuestionDrop" & QuizQuestionNumber 
    .OnAction = "recordAnswer" 
End With 

Number = 1 
For Each Q In AnsRng 
    wsBank.DropDowns("QuestionDrop" & QuizQuestionNumber).AddItem Number & " - " & Q 
    Number = Number + 1 
Next Q 

그리고 아래 확인란을 만드는 오전 : 나는 다음과 같이 루프로 드롭 다운을 만드는 오전 같은 행에있는 드롭 다운을 찾고 싶습니다. 그래서 모양을 반복하고 도형이 드롭 다운인지 확인한 다음 BottomRight Cell 속성을 확인하여 'True'가 포함 된 행과 일치하는지 확인합니다. '. 이것이 가능합니까? 내가 가지고 지금까지 같이 당신은 데이터 유효성 검사를위한 그 드롭 다운을 찾을 수

Sub IdentifyShapes() 
    Dim s As Shape 
    For Each s In ActiveSheet.Shapes 
     MsgBox s.Type & vbCrLf & s.Name 
    Next s 
End Sub 

유형을 8을하고 드롭 다운 1
같은 이름을 가지고 :

wsBank.Activate 
With wsBank 
    IndicatorLstRow = .Range("C" & .Rows.Count).End(xlUp).Row 
    Set IndicatorRng = wsBank.Range("B4:B" & IndicatorLstRow) 
End With 

For Each c In IndicatorRng 
    If c = "True" Then 
     QuestionRow = c.Row 

      For Each ComboShape In wsBank.Shapes 
       test = ComboShape.Type 
      Next ComboShape 

    End If 
Next c 

답변

2

올바른 길을 가고 있습니다. 먼저 "참"이 들어있는 셀을 찾으십시오. 그러면 셀 주소가 생기고 셀 행이 생깁니다. 다음 단순히 모양을 통해 반복하고 그들의 .TopLeftCell을 찾아 행을 가져와 일치하는지 확인하십시오. 여기

는 예 ( 안된) 당신의 도움이 게리의 학생에 대한

Dim shp As Shape 

For Each c In IndicatorRng 
    If c = "True" Then 
     QuestionRow = c.Row 
     For Each shp In wsBank.Shapes 
      If shp.Type = 8 And shp.Name Like "Drop*" Then 
       If shp.TopLeftCell.Row = QuestionRow Then 
        ' 
        '~~> Rest of the code 
        ' 
       End If 
      End If 
     Next shp 
    End If 
Next c 
+0

Siddharth 대단히 감사합니다. 나는 'Gary 's Student'가 아래에 쓴 것과 비슷한 모양을하고 있었고 모양 유형 8을 보았습니다. 그러나 나는 워크 시트에 체크 상자와 드롭 다운을 모두 가지고 있었기 때문에 저를 버렸습니다. 감사합니다 aagin! – mccreaVBA

1

을 실행하면 실험은 시트의 모든 도형에 대한 유형을 산출합니다.

+0

감사합니다! – mccreaVBA

관련 문제