Question : excel vba number format file size
Answered by : quaint-quetzal-6cqy8te5n8up
[<1000000]0.00," KB";[<1000000000]0.00,," MB";0.00,,," GB"
Source : https://social.msdn.microsoft.com/Forums/office/en-US/6a73c276-4650-42f3-b2cd-852810616d2c/file-size-number-format?forum=exceldev | Last Update : Wed, 03 Feb 21
Question : excel vba number format file size
Answered by : quaint-quetzal-6cqy8te5n8up
Select Case objFile.Size Case 0 To 1023 Cells(NextRow, "D").Value = Format(objFile.Size, "0") & "B" Case 1024 To 1048575 Cells(NextRow, "D").Value = Format(objFile.Size / 1024, "0") & "KB" Case 1048576 To 1073741823 Cells(NextRow, "D").Value = Format(objFile.Size / 1048576, "0") & "MB" Case 1073741824 To 1.11111111111074E+20 Cells(NextRow, "D").Value = Format(objFile.Size / 1073741823, "0.00") & "GB"
End Select
Source : https://www.mrexcel.com/board/threads/convert-filesize-to-kb-mb-gb-etc-in-vba.829884/ | Last Update : Wed, 03 Feb 21