当其他列被隐藏时,如何修复仅对几列进行排序后的数据库

当其他列被隐藏时,如何修复仅对几列进行排序后的数据库

我对一个包含大量信息的大型数据库进行了排序,当时隐藏了几列。其中一列是按日期排序的,当我取消隐藏所有列时,整个数据库中一半的信息现在都是错误的。

首先,这可能是导致数据移位单元的原因吗?其次,有没有办法将其改回来?

答案1

这并不能解决您当前的问题,但我无法将大量代码粘贴到注释中。这是我放入任何我想确保备份的工作簿中的一些 VBA。每当调用它时,它都会进行备份。我通常从事件中调用它Workbook_Open。如果您不选择时间戳,它每天最多备份一次。对于文件我真的我很紧张,我也用事件的时间戳来调用该函数Workbook_AfterSave

Option Explicit

'This function saves a datestamped or timestamped copy of the file in a folders in the same location as the file
'It is typically called from the ThisWorkbook object with something like:
'Private Sub Workbook_Open()
'    BackupThisFile
'End Sub

Function BackupThisFile(Optional AddTimestamp As Boolean = False)

    Dim fPath As String
    Dim fName As String
    Dim fExt As String
    Dim iExt As Integer
    Const backupFolder As String = "Backups"

    'Get file path
    fPath = ThisWorkbook.path
    If Right(fPath, 1) <> Application.PathSeparator Then fPath = fPath & Application.PathSeparator

    'Add the backup folder name
    fPath = fPath & backupFolder
    If Right(fPath, 1) <> Application.PathSeparator Then fPath = fPath & Application.PathSeparator

    'Create the backup directory if it doesn't already exist
    On Error Resume Next
        MkDir fPath
    On Error GoTo 0

    'Get file name
    fName = ThisWorkbook.Name                   'Get file name with extension
    iExt = InStrRev(fName, ".")                 'Find the . separating name from extension
    fExt = Right(fName, Len(fName) - iExt + 1)  'Saves the extension
    fName = Left(fName, iExt - 1)               'Clips the extension

    'Compile path, file name, date stamp, and extension into one variable
    fPath = fPath & fName & " " & Format(Date, "yyyy-mm-dd")

    'Add timestamp if required
    If AddTimestamp Then fPath = fPath & " " & Format(Now, "hhmmss")

    'Add the file extension
    fPath = fPath & fExt

    'Save a copy if it doesn't already exist
    Dim fso: Set fso = CreateObject("Scripting.FileSystemObject")
    If Not fso.fileExists(fPath) Then ThisWorkbook.SaveCopyAs fPath

End Function

相关内容