我有一个脚本可以检查工作表中的新商店。如果它找到一个新商店,它应该打开一个表单并提示用户选择一个商店类别,然后单击确定。当用户单击确定时,应选择下拉列表中的值,然后表单关闭并继续循环。
表格称为“shopkat”
这是它的工作原理:
For i = LBound(distshops) To UBound(distshops)
If Not IsEmpty(distshops(i)) Then
curcell = getrows
curshop = distshops(i)
findout = checkifinsheet(curshop)
If findout = False Then
Cells(curcell + 1, 1) = curshop
'show form
shopkat.Show vbModal
'shop current shop
shopkat.shop.Caption = curshop
'Get value from combo
Cells(curcell + 1, 2) = shopkat.shopkatcombo.value
'if user click ok then continue
End If
End If
Next i
谁能帮忙。非常感谢!
//////////////////////////// 更新 ///////////////////// ////////// 模块1:
Public curcell As Long
Dim ws As Worksheet
表格购物:
Private Sub shopkatok_Click()
If Not shopkat.shopkatcombo.value = "" Then
ws.Cells(curcell + 1, 2) = shopkat.shopkatcombo.value
Unload Me
End If
End Sub
循环表(商店类别)
Set ws = ThisWorkbook.Sheets("Shopcategories")
For i = LBound(distshops) To UBound(distshops)
If Not IsEmpty(distshops(i)) Then
curcell = getrows()
curshop = distshops(i)
findout = checkifinsheet(curshop)
If findout = False Then
shopkat.shop.Caption = curshop
'show form
shopkat.Show
If Not IsEmpty(Cells(curcell + 1, 2).value) Then
ws.Cells(curcell + 1, 1) = curshop
End If
End If
End If
Next i