Excel VBA Macro : Retrieve Hard Disk Drives Using macros in Excel
     Excel Recover Partitions with Excel VBA:

  • Add Reference to Microsoft Scripting.FileSystemObject>
  • Recover And browse the collection of disks and write properties in the cellsli>
Sub Read_Drives_In_Excel_VBA()

'Excel VBA CODE-MyExcelTools.com

On Error Resume Next
Dim fso
'Declare the variable
'Set the object type Scripting
Set fso = CreateObject("Scripting.FileSystemObject")
'Set the drives collection
Set Drives = fso.Drives

Dim count As Byte

For Each u In Drives
‘navigate in the collection

'Drive Columns(1).Cells(1).Offset(count, 0).Value = u.DriveLetter

'Free Space
 Columns(2).Cells(1).Offset(count, 0).Value = FormatNumber(u.AvailableSpace / 1024 / 1024 / 1024, 2, , , -1) count = count + 1

'clear the objects
Set Drives = Nothing
Set fso = Nothing

End Sub
Excel VBA Code - Preview