我想把a列的字符串作为sheet名处理,excel中应该如何编写程序,谢谢
a列动态的值,应该先判断是否不为空吧,这个怎么写,求程序,谢谢
判断方法是:
if typeName(curRange) <> "Nothing" then
...
end if
下面是几个例子:
例1:
If Cells(1,1).value<>"" then '如果A1不为空,第一个工作薄的名称是A1单元格的值
SHEETS(1).name=cells(1,1).value
end if
也可以加一个循环,直到找到A列不为空的单元格
例2:
dim x as range
for each x in range("A1:A65536")
if x.value<>"" then
sheets(1).name=x.value
exit for
end if
next
if typeName(curRange) <> "Nothing" then
...
end if
下面是几个例子:
例1:
If Cells(1,1).value<>"" then '如果A1不为空,第一个工作薄的名称是A1单元格的值
SHEETS(1).name=cells(1,1).value
end if
也可以加一个循环,直到找到A列不为空的单元格
例2:
dim x as range
for each x in range("A1:A65536")
if x.value<>"" then
sheets(1).name=x.value
exit for
end if
next
温馨提示:答案为网友推荐,仅供参考
第1个回答 推荐于2017-10-02
例1:
If Cells(1,1).value<>"" then '如果A1不为空,第一个工作薄的名称是A1单元格的值
SHEETS(1).name=cells(1,1).value
end if
也可以加一个循环,直到找到A列不为空的单元格
例2:
dim x as range
for each x in range("A1:A65536")
if x.value<>"" then
sheets(1).name=x.value
exit for
end if
next本回答被提问者采纳
If Cells(1,1).value<>"" then '如果A1不为空,第一个工作薄的名称是A1单元格的值
SHEETS(1).name=cells(1,1).value
end if
也可以加一个循环,直到找到A列不为空的单元格
例2:
dim x as range
for each x in range("A1:A65536")
if x.value<>"" then
sheets(1).name=x.value
exit for
end if
next本回答被提问者采纳