Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/28.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Excel 与按钮结合使用的组合框_Excel_Vba - Fatal编程技术网

Excel 与按钮结合使用的组合框

Excel 与按钮结合使用的组合框,excel,vba,Excel,Vba,我有一个组合框;进行选择时,用该值填充链接的单元格。我想重复这个过程,但每次都要直接填充下面的单元格。我曾想过使用一个按钮,但不确定如何创建宏来实现这一点。非常感谢您的帮助。下面的单元格-我想您希望将链接的单元格更改为下一行吗? 这是有效的;代码被注释 Option Explicit Dim insw& ' global needed because changing the row calls the _Change Sub. ' This is an "in-process" sw

我有一个组合框;进行选择时,用该值填充链接的单元格。我想重复这个过程,但每次都要直接填充下面的单元格。我曾想过使用一个按钮,但不确定如何创建宏来实现这一点。非常感谢您的帮助。

下面的单元格-我想您希望将链接的单元格更改为下一行吗?
这是有效的;代码被注释

Option Explicit

Dim insw& ' global needed because changing the row calls the _Change Sub.
' This is an "in-process" switch.

Sub combobox1Reset() ' reset to B5
  ComboBox1.Clear
  ComboBox1.AddItem "One"
  ComboBox1.AddItem "Two"
  ComboBox1.AddItem "Three"
  insw = 1
  ComboBox1.LinkedCell = Cells(5, 2).Address ' B5
  insw = 0
End Sub

Private Sub ComboBox1_Change()
  Dim iRow&, iCol&, s1$, zCell As Range
  If insw Then Exit Sub ' skip row change
  s1 = ComboBox1.LinkedCell ' old addr
  Set zCell = Range(s1) ' get row, col
  iRow = zCell.Row + 1 ' increment
  iCol = zCell.Column
  insw = 1 ' skip row change
  ComboBox1.LinkedCell = Cells(iRow, iCol).Address
  insw = 0
End Sub