0
我在上遵循以下格式Excel的VBA - 斯普利特各條線和Calulate價值
12/1/2013-$590.00
10/1/2014-$602.00
基本上就是我想要做的就是劇本美元后閱讀次數細胞多行簽署和採取最高的一個,並驗證它是高於當前的租金,如果是,然後將其更改爲新的。
我試圖使用下面的代碼,但我有一些問題。 任何幫助,將不勝感激
'Start Rent Update check
' First, lets check if the text in the pointed cell is divided into separate rows at all
' If this is not the case, we will display the whole text
WhereFrom = NewRent
Temporary = InStr(WhereFrom, Chr(10))
MsgBox (Temporary)
If Temporary = 0 Then
GetTextRow = WhereFrom ' return text from pointed cell
intPos = InStr(1, GetTextRow, "$")
If intPos > 0 Then
MsgBox ("Storage Variable " & StorageVariable)
StorageVariable = CInt(Right(GetTextRow, Len(GetTextRow) - intPos))
If StorageVariable > 100 Then
If StorageVariable > Rent Then
Rent = StorageVariable
End If
Else
Parking = StorageVariable
End If
End If
Else
' lets also check if the row number the user provided is not too big.
TemporaryArray = Split(WhereFrom, Chr(10))
Do While Not (RowNumber - 1 > UBound(TemporaryArray) Or _
RowNumber = 0)
' if everything is all right the function returns (displays) the chosen row
GetTextRow = TemporaryArray(RowNumber - 1)
intPos = InStr(1, GetTextRow, "$")
MsgBox (intPos)
If intPos > 0 Then
MsgBox (StorageVariable)
StorageVariable = CInt(Right(GetTextRow, Len(GetTextRow) - intPos))
If StorageVariable > 100 Then
If StorageVariable > Rent Then
Rent = StorageVariable
End If
Else
Parking = StorageVariable
End If
RowNumber = RowNumber + 1
End If
Loop
End If
'Check end of rent update
那麼什麼是真正的問題/問題? – 2013-12-18 20:53:32
它目前沒有工作,數字沒有取代目前存儲在租金變量中的較小數字 – MrToast
我從來沒有信任我的計算與'right' - 我會使用'StorageVariable = CInt(mid(GetTextRow,intPos + 1) )'(避免$符號的+1) – SeanC