以下过程旨在搜索通过文件对话框打开的工作簿的每个工作表。然后它搜索一个句子并设置该行,然后搜索该行中的值。
打开文件后,它会遍历工作簿的每个工作表,但似乎是指的是打开工作簿的值。如果在封面上打开,有时会引用该表中的值。
我做错了什么? 抱歉格式不正确。
`Sub FindPlanswGI()
Dim wb As Workbook
Dim wb1 As Workbook
Dim ws As Worksheet
Dim CRD As String
CRD = FolderSelection
Set wb1 = Workbooks.Open(CRD)
For Each ws In wb1.Sheets
Dim NHGI As Range
Dim MX As Range
Dim NH As Range
Dim LC As Long
Dim NHV As Range
Dim MXV As Range
Dim i As Long
Set NH = ws.Range("B:B").Find("Searching for this non sentence.")
Set MX = ws.Range("B:B").Find("Searching for this non sentence too.")
If NH Is Nothing Then
MsgBox "Not here" + ws.Name
GoTo NextWSH
Else
MsgBox "here" + ws.Name + NH.Address + MX.Address
End If
'i = 4 to LC
'LastRow
Set MXV = Cells(MX.Row, 4)
Set NHGI = Cells(NH.Row, 4)
Set NHV = Cells(NHGI.Row + 1, 4)
If NHGI = "N/A" Or NHV = MXV Then
MsgBox "Here" + ws.Name + NHGI.Address
Else: MsgBox "No" + ws.Name + NHGI.Address
End If
NextWSH:
Next ws
wb1.Close
End Sub
答案 0 :(得分:1)
我认为你的MXV,NHGI和NHV范围的Cell分配需要ws工作表对象。所以:
def changeprofile(request):
form = Profile(request.POST or None, request.FILES or None)
if form.is_valid():
profile = form.save(commit=False)
profile.user = request.user
profile.save()
return render(request, 'myaccount.html', {"Profile":form})