繁体   English   中英

逗号分隔符:使用excel宏忽略数据中的逗号

[英]Comma Separator: Ignore the comma within the data using excel macro

我是使用Excel宏vba的新手,并且在下拉列表中列出数据时遇到问题。 我想创建一个下拉列表,并且在一行记录中有一个逗号,但是我的代码将其分开。 这是我的代码。

码:

Dim ShipAddress As String
Dim MyList5() As String
ReDim MyList5(ShipAddressCount)

For h = 1 To ShipAddressCount
    ShipAddress = rsShipAddress!ShippingAddress
    MyList5(h) = ShipAddress
    rsShipAddress.MoveNext
Next


 With Range("E4:E" + cnt).Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, _
Operator:=xlBetween, Formula1:=Join(MyList5, ",")
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With

当列表具有“名称,名称”的下拉记录时,它将被视为两行。 我想在列表中有一条记录,并在一行中有一个逗号。 你们还有其他解决方法吗?

任何帮助将不胜感激。 谢谢。

您可以将值放入一列单元格中,将其设置为“命名范围”(我通常以“ DrpDwn_”开头以显示它们是“下拉列表”),然后使用该列表将其指向“命名范围”。

例如,如果您的命名范围是“ DrpDwn_Shipping”,则可以使用Formula1:="=DrpDwn_Shipping"

这种方法的问题是,当然,对于每个不同的下拉列表,您都需要一个列和一个“命名范围”,最好在一个非常隐藏的工作表上。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM