我试图找到一个我知道它在那里的单元格,但总是告诉我那儿没有。 Rng =没事
Set ws = Worksheets("Sheet1")
ws.Cells.UnMerge
Range("A1").Select
Set Rng = ws.Cells.find(What:="31/1/2019", After:=ActiveCell,
LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)
Range(Selection, Selection.Offset(0, 9)).Select
Selection.Copy
Workbooks("Other.xlsm").Activate
ActiveWorkbook.Sheets("Sheet1").Select
Range("A1").End(xlDown).Offset(1, 0).Select
Selection.PasteSpecial xlValues
Workbooks("Other.xlsx").Close SaveChanges:=False
答案 0 :(得分:1)
考虑:
Label Text="{Binding YourFloatValue, StringFormat='{0:D2}'}" />
(您可能还有其他错误)
答案 1 :(得分:1)
代码正在寻找字符串"31/1/2019"
,并且在Excel中该字符串未显示为日期。要将其显示为日期,请更改月份和日期的名称,例如:"1/31/2019"
:
Sub TestMe()
Dim rng As Range
Set rng = Worksheets(1).Cells.Find(What:="1/31/2019", After:=ActiveCell, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)
If Not rng Is Nothing Then MsgBox rng.Address
End Sub
当然,有更好的方法可以做到这一点,例如编写What:=DateSerial(2019, 1, 31)
而不关心首先是什么,然后是第二位(如加里的解决方案一样)。
有关Excel和VBA格式化日期并进行搜索的方式,请在此处查看: