如果数据验证显示是,我正尝试自动填充单元格值。基本上,如果联系地址与站点地址相同,那么它会将站点地址拉到联系地址。
到目前为止,我已经尝试过这段代码:
Sub PopulateSite()
Dim SiteName As Long
Dim Address1 As Long
Dim Address2 As Long
Dim Town As Long
Dim County As Long
Dim Postcode As Long
SiteName = Sheets("HV.Select Site Set Up").Range("E7")
Address1 = Sheets("HV.Select Site Set Up").Range("E17")
Address2 = Sheets("HV.Select Site Set Up").Range("E19")
Town = Sheets("HV.Select Site Set Up").Range("E21")
County = Sheets("HV.Select Site Set Up").Range("E23")
Postcode = Sheets("HV.Select Site Set Up").Range("E25")
If Sheets("HV.Select Site Set Up").Range("G29") = "Yes" Then
Sheets("HV.Select Site Set Up").Range("E31") = SiteName
Sheets("HV.Select Site Set Up").Range("E41") = Address1
Sheets("HV.Select Site Set Up").Range("E43") = Address2
Sheets("HV.Select Site Set Up").Range("E45") = Town
Sheets("HV.Select Site Set Up").Range("E47") = County
Sheets("HV.Select Site Set Up").Range("E49") = Postcode
End If
End Sub
由于某种未知原因,这是行不通的。拜托,有人可以帮帮我吗?
答案 0 :(得分:3)
您的类型声明(我假设基于变量名称)是错误的。我猜这些值中的大多数是String
类型(Long
用于数字整数),所以如果你将类型声明更改为As String
,它应该像你一样工作需要。