私はちょうど大きな問題を抱えています!データ検証の間接的な機能vba
私はマクロを2つの検証リストで実行しますが、最初のリストは機能しますが、間接関数を使用して私はcuestionを持っています。
最初のリストは、Cell B17である
私が機能している研究が、B17を参照して、リストをドロップダウンいけないコードで、参照間接的機能を行うためのB17が、doesntの仕事を取る必要があります私の第二のリストだけこのセル内のテキストを「コピー」します。
これは私が問題は間接の結果は、「$ B $ 17」であるので、私はExcelの検証リストをすれば、結果は=間接的である文字列であることだと思います私のコード
Sub insertfamilyValidate()
' Selecciona la celda basica de indirecto
' insertfamilyValidate Macro
'
' Acceso directo: CTRL+f
'
Rows("17:18").Select
Selection.Insert Shift:=xlDown
Range("A17:M17").Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 39423
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
Selection.Borders(xlInsideVertical).LineStyle = xlNone
Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
Range("A17").Select
ActiveCell.FormulaR1C1 = "Código"
Range("B17:D17").Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Selection.Merge
Range("A17").Select
Selection.Font.Bold = True
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Range("B17:D17").Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=Familias"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
Range("E17").Select
ActiveCell.FormulaR1C1 = "Pax Sentadas"
Range("F17").Select
ActiveCell.FormulaR1C1 = "Cant."
Range("G17").Select
ActiveCell.FormulaR1C1 = "Cost. Unit."
Range("H17").Select
ActiveCell.FormulaR1C1 = "Días"
Range("I17").Select
ActiveCell.FormulaR1C1 = "Total"
Range("J17").Select
ActiveCell.FormulaR1C1 = "%"
Range("K17").Select
ActiveCell.FormulaR1C1 = "Descuento"
Range("L17").Select
ActiveCell.FormulaR1C1 = "Sub total"
Range("M17").Select
ActiveCell.FormulaR1C1 = "Total"
Range("A17:M17").Select
Range("M17").Activate
Selection.Font.Bold = True
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
End With
Dim MiCelda As Range
Set MiCelda = Worksheets("cotizacion").Cells(17, 2)
With Range("A18").Validation
' clear previous validation to existing cell
.Delete
' *** Added this debug part ***
Dim ValidStr As String
ValidStr = "=INDIRECT(" & MiCelda.Address(True, True) & ")"
Debug.Print ValidStr
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=INDIRECT(" & MiCelda.Address(True, True) & ")"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
Range("B18:D18").Select
Selection.Merge
ActiveCell.FormulaR1C1 = "=VLOOKUP(RC1,LISTAPRECIOS2016,2,FALSE)"
Range("E18").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(RC1,LISTAPRECIOS2016,3,FALSE)"
Range("F18").Select
ActiveCell.FormulaR1C1 = "1"
Range("G18").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(RC1,LISTAPRECIOS2016,9,FALSE)"
Range("H18").Select
ActiveCell.FormulaR1C1 = "1"
Range("I18").Select
Application.WindowState = xlMinimized
Application.WindowState = xlNormal
ActiveCell.FormulaR1C1 = "=RC[-3]*RC[-2]*RC[-1]"
Range("J18").Select
ActiveCell.FormulaR1C1 = "0"
Range("K18").Select
ActiveCell.FormulaR1C1 = "=RC[-2]*RC[-1]"
Range("L18").Select
ActiveCell.FormulaR1C1 = "=RC[-3]-RC[-1]"
Range("M18").Select
ActiveCell.FormulaR1C1 = "=SUM(RC[-1])"
Range("G18").Select
Selection.NumberFormat = "_($* #,##0.00_);_($* (#,##0.00);_($* ""-""??_);_(@_)"
Range("I18").Select
Selection.NumberFormat = "_($* #,##0.00_);_($* (#,##0.00);_($* ""-""??_);_(@_)"
Range("J18").Select
Selection.Style = "Percent"
Range("K18").Select
Selection.NumberFormat = "_($* #,##0.00_);_($* (#,##0.00);_($* ""-""??_);_(@_)"
Range("L18").Select
Selection.NumberFormat = "_($* #,##0.00_);_($* (#,##0.00);_($* ""-""??_);_(@_)"
Range("M18").Select
Selection.NumberFormat = "_($* #,##0.00_);_($* (#,##0.00);_($* ""-""??_);_(@_)"
Range("A18").Select
End Sub
です($ B $ 17)引用符なしでこれはfuncionalです、私は引用符を削除しようとすると、最初はokでしたが、その後はエラー1004です。
私は最小のエラーがあるか、それを理解できない。 ヘルプがありますか?
私は.deleteを追加しますが、エラーは同じです。
これはあなたのValidation Formula
あなたが追加することにより、以前のものをクリアする必要があります...デバッグとスクリーンショットがここにありますセットアップする前に
おかげで同じエラーですコード1004 ... –
@ LadyMuerteしかし、あなたは '.Add Type:= xlValidateList'の次の行をコピーしませんでした。" "" –
を除いて私はそれを行いますが、引用符を削除するとエラー1004、3つの引用符で関数は完了していますが、a18のセルb17の内容があります。 –