cell.Offset(0, 1).Font.Color = RGB(255, 0, 0)
cell.Offset(0, 1).Font.Color = RGB(0, 255, 0)
If cell.Value <> "" Then
Public Function TakeFirstThreeReferences(inReference As String) As String
Dim tmpStrings() As String
TakeFirstThreeReferences = ""
tmpStrings = Split(inReference, ", ")
If UBound(tmpStrings) = 0 Then
TakeFirstThreeReferences = tmpStrings(0)
End If
If UBound(tmpStrings) = 1 Then
TakeFirstThreeReferences = tmpStrings(0) & ", " & vbCrLf & tmpStrings(1)
End If
If UBound(tmpStrings) >= 2 Then
TakeFirstThreeReferences = tmpStrings(0) & ", " & vbCrLf & tmpStrings(1) & ", " & vbCrLf & tmpStrings(2)
End If
End Function
Dim Number, Minimum, Room, Product, Data, X As Double
вовсе не означает, что все переменные имеют тип Double
. В VBA каждой переменной надо задавать отдельный тип: Dim Number As Integer, Minimum As Double, Data As Double, Room As Integer, Product As Double, X As Double
Double
только последнюю переменную. Все остальные инициализируются как Variant
. Таким образом, Data
у Вас получается текстовой переменной поскольку извлекается из InputBox
. Это приводит к тому что "-1" < "-2" (1 < 2). If Data > Minimum Then
Вы находите не минимум, а максимум. If X = 1 Then
Minimum = Data
Room = X
End If
If Data < Minimum Then
Minimum = Data
Room = X
End If
If Data < 0 Then
If Product = 0 Then
Product = Data
Else
Product = Product * Data
End If
End If
Public Declare Function URLDownloadToFile Lib "urlmon" Alias _
"URLDownloadToFileA" (ByVal pCaller As Long, _
ByVal szURL As String, _
ByVal szFileName As String, _
ByVal dwReserved As Long, _
ByVal lpfnCB As Long) As Long
' http://site.ru/images/site/site_ru_logo.png
Sub Start()
Call DownloadToFile("http://site.ru/images/site/site_ru_logo.png", "D:\123.png")
End Sub
Public Sub DownloadToFile(url$, FileName$)
Dim lngRetVal&
lngRetVal = URLDownloadToFile(0, url, FileName, 0, 0)
If lngRetVal <> 0 Then
MsgBox "Error in DownloadToFile: Can't download from " & url & " to " & FileName
End If
End Sub
Private Sub TextBox1_Change()
Label1.Width = UserForm1.Width
Label1.Caption = TextBox1.Text
If Label1.Width > TextBox1.Width Then
Label1.Font.Size = Label1.Font.Size * (TextBox1.Width / Label1.Width / 1.1)
TextBox1.Font.Size = Label1.Font.Size
End If
End Sub
=INT(A1*24)+(A1*24-INT(A1*24))*60/100