Excel VBA 数据视图和查询实例

Private Sub Workbook_Open()
    Sheets("营业部").Select
    
    '行遍历
    For i = 5 To 368
        '列遍历
        For j = 1 To 32
            Cells(i, j + 5).Select
            
            Dim str As String
            str = "=IF(ISNUMBER(VLOOKUP(R" & CStr(i) & "C3,总表!R5C3:R1466C37," & CStr(j + 3) & ",false)),VLOOKUP(R" & CStr(i) & "C3,总表!R5C3:R1466C37," & CStr(j + 3) & ",false),"""")"
           
            ActiveCell.FormulaR1C1 = str
        Next j
        
    Next i
    ActiveWorkbook.Save
    
    
End Sub


Sub excel去掉公式()
    Sheets("营业部").Select
        Sheets("营业部").UsedRange = Sheets("营业部").UsedRange.Value
   
End Sub

你可能感兴趣的:(Excel VBA 数据视图和查询实例)