私は多くのスプレッドシートに基づいてデータベースを作成しようとしています。私は、必要な情報をきちんとフォーマットされたテーブルに引き出す多くのスプレッドシートを目指しています。私はちょうど始めたので、私は必要なものを引き出すためにいくつかの関数を書いています。私はそれらを変数に格納して、テーブルに入れます。日付の値が変更されます
私は検索文字列の範囲書かれており、その隣のセル内の情報を引き出すしている機能。それは文字列のためにうまくいくようです。
誰もが日付で何が起こっているかを説明できますか?英国の形式dd/mm/yyyyで日付を出力したい。現在、有効期限の01/06/2018の次の日付は英国形式です。私がそれをデバッグして印刷物を入れると、それは英国の形式で出てきます。それが格納されているセルのフォーマットをチェックすると、それが返されるセルは両方ともUKフォーマットです。それは06/01/2018として出てきます。
可能な場合には、何が起こっているかの説明が答えに含まれてではなく、私はそれが実際にそれを解釈する方法を学ぶことができるようにソリューション「ただ、これにコードを変更」されるだろうか?
ご協力いただければ幸いです。
ここでコード
Private Sub Main()
'Turn off screen updating
Application.ScreenUpdating = False
'Define the variables
Dim Coverholder As String
Dim SearchRange As Range
'set the range to search
Set SearchRange = Sheets("2017 Property").Range("A1:AZ100")
'testing
Range("A1").Value = GetNextTo(SearchRange, "*Expiry*")
Debug.Print GetNextTo(SearchRange, "*Expiry*")
'Reset the position of the selection
Range("A1").Select
'Turn on the screen updating
Application.ScreenUpdating = True
End Sub
'Function to return the value one cell to the right of a search value
Private Function GetNextTo(SearchRange As Range, FindString As String) As String
'Define variables
Dim Rng As Range
'Clean the string
If Trim(FindString) <> "" Then
'use the search range
With SearchRange
Set Rng = .Find(What:=FindString, _
After:=.Cells(.Cells.Count), _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
'If value found
If Not Rng Is Nothing Then
Application.Goto Rng.Offset(0, 1)
'If value not found
Else
MsgBox "Nothing found"
End If
End With
End If
GetNextTo = ActiveCell.Value
End Function
私は本当にあなたにそれを説明したいと思いますが、私はそう長く検索ともstackoverlowに尋ねたが、良い説明を見つけたことがありません。フォーマット(日付、 "dd/mm/yyyy") – Doomenik
Offtopic: 'Application.ScreenUpdating = True'は画面の更新をオフにしません。 –
https://stackoverflow.com/questions/37100821/change -date-format-substitute-or-replace/37101358#37101358こことここにhttps://stackoverflow.com/questions/38000194/difference-between-date-and-time-w-out-work-week-excel/38001028#38001028一部のスタックオーバーフローの説明があります – Doomenik