Worksheets(1).Cells.Delete和之间有什么区别Worksheets(1).Cells.Clear?
我之所以这样问是因为我一直习惯于.Clear清除工作表的内容,但是在我以前的文章中,我发现Worksheets(1).Cells.Delete不仅删除我的工作表的内容,还将列设置为默认宽度!
谁能解释我的区别?我还能给范围.Delete吗?
更新
我为什么要这么做
Dim delete as Range
Set delete = ThisWorkbook.Worksheets("Someting").Range("A1:D4")
delete.Clear 'It does clear my content
delete.Delete 'Does the same fucntion as .Clear? I mean It doesn't delete all the formatting and width of the cells
Run Code Online (Sandbox Code Playgroud)
也许我正在写这是错误的...
我有一张桌子,数字从1到10。(从D2到M2)
假设A1中有03/09/2019
并且在B1中有06/09/2019
AND在C1中有Hello
在A栏我有从A3到A10的多个单词系列
这是Excel表的示例
我想做的是:在A列中搜索Student一词,找到它后,从A1-> 3 和A2-> 6中获取数字,并在单元格中的C1中写上Hello这个词。在找到的单词Student的行中转到3至6
所以我的输出是这样的:
到目前为止,这是我的代码:
Dim Cell As Range
Columns("A:A").Select
Set Cell = Selection.Find(What:="Student", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)
If Cell Is Nothing Then
MsgBox "Word not found"
Else
MsgBox "Word found"
End If
Run Code Online (Sandbox Code Playgroud)
基本上我可以找到单词Student,但是不知道如何在3到6之间的单元格中写Hello
我有很多 ELSE IF 语句,但我想问一下是否有更好的编码方式,这是我的代码。
if (txtMyTime.Text == "00:00")
{
myInteger = 0;
}
else if (txtMyTime.Text == "00:30")
{
myInteger = 0.5;
}
else if (txtMyTime.Text == "01:00")
{
myInteger = 1;
}
else if (txtMyTime.Text == "01:30")
{
myInteger = 1.5;
}
else if (txtMyTime.Text == "02:00")
{
myInteger = 2;
}
else if (txtMyTime.Text == "02:30")
{
myInteger = 2.5;
}
else if (txtMyTime.Text == "03:00")
{
myInteger = 3;
}
else if (txtMyTime.Text == "03:30")
{
myInteger …Run Code Online (Sandbox Code Playgroud) 如何转换1 1,5 2 2,5 3 3,5成TimeSpan在C#中?
1 会是01:00
1,5 会是01:30
2 会是02:00
2,5 会是02:30
我已经试过了
string myTime = "1";
TimeSpan finalTime = TimeSpan.ParseExact(myTime, "hh:mm", System.Globalization.CultureInfo.CurrentCulture);
Run Code Online (Sandbox Code Playgroud)
但我收到以下错误
输入字符串格式不正确。