我正在尝试将用户表单输入与excel中的一列数字进行比较;找到我的用户表单输入项小于或等于的数字,并在与之比较的单元格旁边为该单元格分配一个变量值(即,如果Input小于或等于A2,则将变量设置为等于B20)执行此操作时,无论输入值是否小于A列,它都会为我提供B列中的最后一个值。
我在If Then之后尝试了Exit For,但这只是在第一次迭代后将其停止。
Private Sub CommandButton2_Click()
Dim TextBox5 As Integer
If UserForm1.OptionButtonRes.Value = True Then
Dim i As Integer
For i = 1 To 216 Step 1
If Sheet2.Cells(i, 1).Value >= TextBox5 Then
ValueCharge = Sheet2.Cells(i, 2).Value
End If
Next i
End If
MsgBox (ValueCharge)
答案 0 :(得分:1)
TextBox5是仅显示数字的文本。您需要转换为真实的数值才能进行有效的比较。
do shell script "
#!/bin/bash
rpUser=" & fcName & "." & lcName & "
echo $rpUser
echo ${rpUser}
if id -u $rpUser >/dev/null 2>&1; then
syslog -s -l error 'User Account Already Exists'
sleep 1
else
LastID=`dscl . -list /Users UniqueID | awk '{print $2}' | sort -n | tail -1`
NextID=$((LastID + 1))
SECONDARY_GROUP='admin _lpadmin _appserveradm _appserverusr' # for an admin user
# Creating the user account by running dscl.
sudo dscl . -create /Users/$rpUser
sudo dscl . -create /Users/$rpUser UserShell /bin/bash
sudo dscl . -create /Users/$rpUser RealName " & fcName & "' '" & lcName & "
dscl . create /Users/$rpUser UniqueID $NextID
sudo dscl . -create /Users/$rpUser NFSHomeDirectory /Users/$rpUser
sudo dscl . -passwd /Users/$rpUser Read&See1
sudo dscl . -create /Users/$rpUser PrimaryGroupID 20
dseditgroup -o edit -t user -a $rpUser $SECONDARY_GROUP
cp -n -R /System/Library/'User Template'/English.lproj/ /Users/$rpUser
chown -R $rpUser:staff /Users/$rpUser
# Create the home directory
#sudo createhomedir -c -u $rpUser
#createhomedir -c 2>&1 | grep -v 'shell-init'
fi
DIRECTORY=/Users/$rpUser
if id -u $rpUser >/dev/null 2>&1 || -d \"${DIRECTORY}\" ; then
sudo syslog -s -l error 'User Account Or Home Directory Already Exists.'
sleep 1
fi
" with administrator privileges