【发布时间】:2011-07-31 11:27:06
【问题描述】:
我实际上需要关于思考过程和选项的帮助,而不是真正的编码方面的帮助。
我希望用户输入他们的邮政编码。然后我需要查看邮政编码的范围。 编辑:因为我来自比利时,邮政编码是 4 个数字长(1000、1500、8380,...)
Zip code: 2800
Range between;
1000-1999
2000-2999
3000-3999
4000-4999
If the range is between one of the following, display all zip codes for that range
Else do nothing
我想出了一个 If, Else 结构。但我想知道是否有更好的选择?
Zip code: 2800
If zip code > 3999 then
'Select all zipcodes within this range
'Range(" .. ").Copy Destination:=Sheets...
ElsIf zip code > 2999 then
'Select all zipcodes within this range
'Range(" .. ").Copy Destination:=Sheets...
Elsif zipcode ....
谢谢。
@@@@@@@@@@@@@
Openshac
我想出了这个。
x = 1
Sheets("Reference").Select
For i = 1 to 115
If Range("A" & i).value > 5999 and Range("A" & i).value < 6000 then
Range("A" & i).copy Destination:=Sheets("Design").Range("A" & x)
x = x + 1
End if
Next i
【问题讨论】:
-
什么是“做某事”?每个邮政编码范围都会改变吗?
-
等一下,我会改的。
-
hmmmm 哪个 (Integer ??) 数大于 (>) 5999 同时小于 (
标签: excel if-statement range vba