excel vba
Excel<FONT face=宋体>编程中,如何将</FONT>Range"A1:F1"<FONT face=宋体>写出?<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></FONT><FONT face=宋体>本人试了:</FONT>cells(1,(1:5))<FONT face=宋体>不行。</FONT><o:p></o:p> 是合并的单元格么? Dim counter as integer
<TABLE class=MsoNormalTable style="MARGIN: auto auto auto 4.4pt; WIDTH: 488pt; BORDER-COLLAPSE: collapse; mso-padding-alt: 0cm 5.4pt 0cm 5.4pt" cellSpacing=0 cellPadding=0 width=651 border=0>
<TBODY>
<TR style="HEIGHT: 14.1pt; mso-yfti-irow: 0">
<TD style="BORDER-RIGHT: #d4d0c8; PADDING-RIGHT: 5.4pt; BORDER-TOP: #d4d0c8; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: #d4d0c8; WIDTH: 162.65pt; PADDING-TOP: 0cm; BORDER-BOTTOM: #d4d0c8; HEIGHT: 14.1pt; BACKGROUND-COLOR: transparent" vAlign=bottom noWrap width=217>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-pagination: widow-orphan" align=left><SPAN style="mso-spacerun: yes"> For counter = 1 To 2</SPAN>
</TD>
<TD style="BORDER-RIGHT: #d4d0c8; PADDING-RIGHT: 5.4pt; BORDER-TOP: #d4d0c8; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: #d4d0c8; WIDTH: 54.2pt; PADDING-TOP: 0cm; BORDER-BOTTOM: #d4d0c8; HEIGHT: 14.1pt; BACKGROUND-COLOR: transparent" vAlign=bottom noWrap width=72>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-pagination: widow-orphan" align=left><?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p> </o:p>
</TD>
<TD style="BORDER-RIGHT: #d4d0c8; PADDING-RIGHT: 5.4pt; BORDER-TOP: #d4d0c8; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: #d4d0c8; WIDTH: 54.2pt; PADDING-TOP: 0cm; BORDER-BOTTOM: #d4d0c8; HEIGHT: 14.1pt; BACKGROUND-COLOR: transparent" vAlign=bottom noWrap width=72>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-pagination: widow-orphan" align=left><o:p> </o:p>
</TD>
<TD style="BORDER-RIGHT: #d4d0c8; PADDING-RIGHT: 5.4pt; BORDER-TOP: #d4d0c8; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: #d4d0c8; WIDTH: 54.2pt; PADDING-TOP: 0cm; BORDER-BOTTOM: #d4d0c8; HEIGHT: 14.1pt; BACKGROUND-COLOR: transparent" vAlign=bottom noWrap width=72>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-pagination: widow-orphan" align=left><o:p> </o:p>
</TD></TR>
<TR style="HEIGHT: 14.1pt; mso-yfti-irow: 1; mso-yfti-lastrow: yes">
<TD style="BORDER-RIGHT: #d4d0c8; PADDING-RIGHT: 5.4pt; BORDER-TOP: #d4d0c8; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: #d4d0c8; WIDTH: 325.25pt; PADDING-TOP: 0cm; BORDER-BOTTOM: #d4d0c8; HEIGHT: 14.1pt; BACKGROUND-COLOR: transparent" vAlign=bottom noWrap width=434 colSpan=4>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-pagination: widow-orphan" align=left><SPAN style="mso-spacerun: yes"> Worksheets("sheet1").Cells(counter, 1).Select<o:p></o:p></SPAN>
</TD></TR></TBODY></TABLE>
这cells(<FONT face=宋体>counter, 1)如何化为非合并的多单元格?</FONT> Sheet1.Range("a1:f1").Select<BR> Sheet1.Range("a1:f1").Select
但对于循环中a1:f1无法自动变化。 你到底想达到什么目的? 你是不是想一行行地读excel表格啊?如果是的话,请试试下面的方法!
Dim counter as integer,str as string
for counter=1 to 2
str="a" & counter& ":" & "f" & counter
Sheet1.Range(str).Select
next counter 随心飘荡 、天涯海角 :
二位好!Range("a1:f1").Select,在循环中的正确写法:Range(cells(1,1),cells(1,6)).Select,可以对cells内部数字用变量置换。
多谢!
-------------------------------------------------
-----cqy 哦,excel我用得不多,谢谢你啦,又学了一招!
页:
[1]