bsharath
asked on
Excel Macro that finds the configuration of machines whose names are in the colum Q. Need a change.
Hi,
Excel Macro that finds the configuration of machines whose names are in the colum Q. Need a change.
The HDD (Hard disk) size thats got to the colum does not get the exact size. i want a round figure size to be mentioned in the excel.
Can anyone help with this.
Regards
sharath
Excel Macro that finds the configuration of machines whose names are in the colum Q. Need a change.
The HDD (Hard disk) size thats got to the colum does not get the exact size. i want a round figure size to be mentioned in the excel.
Can anyone help with this.
Regards
sharath
Sub Get_Configuration_Remote()
'Get the Configuration of a machine Processor,Ram,CDD,FDD,HDD
'Direct Machine
Application.DisplayAlerts = False
Dim objWMI
Dim lngRow As Long, lngRowCount As Long
lngRowCount = Cells(65536, "Q").End(xlUp).Row
'assumes header in row 1
For lngRow = 2 To lngRowCount
If (Cells(lngRow, "W").Value = "Could not be contacted." Or Cells(lngRow, "W").Value = "") And Cells(lngRow, "Q").Value <> "" Then
intHDD1 = 0
intHDD2 = 0
strPC = Cells(lngRow, "Q")
On Error Resume Next
Set objWMI = GetObject("winmgmts:\\" & strPC & "\root\CIMV2")
If Err.Number = 0 Then
Set colItems = objWMI.ExecQuery("Select * From Win32_Processor")
For Each objItem In colItems
strProcessor = Trim(Replace(Replace(objItem.Name, "Intel", ""), "(R)", ""))
Next objItem
Set colItems = objWMI.ExecQuery("Select * From Win32_OperatingSystem")
For Each objItem In colItems
strRAM = returnRAM(objItem.TotalVisibleMemorySize)
Next objItem
Set colItems = objWMI.ExecQuery("Select * From Win32_LogicalDisk")
For Each objItem In colItems
If Not IsNull(objItem.Size) Then
isize = objItem.Size / 1024 / 1024 / 1024
If UCase(objItem.DeviceID) = "C:" Or UCase(objItem.DeviceID) = "D:" Then
intHDD1 = FormatNumber(intHDD1 + isize, 2)
ElseIf UCase(objItem.DeviceID) = "E:" Or UCase(objItem.DeviceID) = "F:" Then
intHDD2 = FormatNumber(intHDD2 + isize, 2)
End If
End If
Next objItem
intHDD1 = intHDD1 & "Gb"
If intHDD2 > 0 Then
intHDD2 = intHDD2 & "Gb"
Else
intHDD2 = ""
End If
Set colItems = objWMI.ExecQuery("Select * from Win32_FloppyDrive")
If colItems.Count = 0 Then
strFloppy = ""
Else
strFloppy = "FDD"
End If
Set colItems = objWMI.ExecQuery("Select * from Win32_CDROMDrive")
If colItems.Count = 0 Then
strCD = ""
Else
strCD = "CDD"
End If
Set colItems = objWMI.ExecQuery("Select * From Win32_NetworkAdapter")
If colItems.Count > 0 Then
End If
With Cells(lngRow, "W")
.Value = strProcessor
.Offset(0, 1).Value = strRAM
.Offset(0, 2).Value = intHDD1
.Offset(0, 3).Value = intHDD2
.Offset(0, 4).Value = strFloppy
.Offset(0, 5).Value = strCD
End With
Else
Cells(lngRow, "W").Value = "Could not be contacted."
On Error GoTo 0
End If ' Err.Number = 0
Set objWMI = Nothing
End If
Next lngRow
Set objWMI = Nothing
Application.DisplayAlerts = True
End Sub
Function returnASize(rawsize As Double, Optional steps As Variant) As String
Dim sz As Double
Dim potentialSize As Variant
Dim arrOffset
returnASize = rawsize
sz = returnASize
If returnASize = "0" Then returnASize = 0
If Not IsMissing(steps) Then
returnASize = 0
For arrOffset = 0 To UBound(steps)
If sz > steps(arrOffset) Then
returnASize = CStr(steps(arrOffset - 1))
Exit For
End If
Next
End If
End Function
Function CBMod(Dividend, Divisor) As Integer
CBMod = Dividend - (Left(Dividend / Divisor & ".", InStr(Dividend / Divisor & ".", ".") - 1) * Divisor)
End Function
Function returnsize(dblSize As Double) As Variant
Dim cbBytes As Integer
Dim cbkilo As Integer
Dim cbMega As Integer
Dim cbGiga As Integer
Dim cbTera As Integer
Dim sizes(0 To 5) As Double
Dim looper As Integer
Dim Kbs() As Variant
Kbs = Array(1024, 768, 640, 512, 384, 256, 128, 0)
Dim minima() As Variant
minima = Array(1024, 0)
Dim halfSplit() As Variant
halfSplit = Array(1024, 512, 0)
sizes(0) = dblSize
For looper = 1 To 5
sizes(looper) = CBMod(sizes(0), 1024)
sizes(0) = (sizes(0) - sizes(looper)) / 1024
Next
sizes(0) = dblSize
returnsize = sizes
End Function
Function returnRAM(sz As Double) As String
Dim memSize() As Double
Dim gbMem As String
Dim halfSplit() As Variant
halfSplit = Array(1024, 512, 0)
memSize = returnsize(1024 * sz)
memSize(3) = returnASize(memSize(3), halfSplit)
returnRAM = memSize(4) + (memSize(3) / (2 ^ 10)) & "Gb"
End Function
ASKER
Thanks
Is there no way to get the HDD the exact size like 500 Gb or 80 Gb and so on...
Say the HDD is 500Gb i get hdd1 as 145+ and Hdd2 as 286+
Can i get them as HDD 1 and with a rounded no
Is there no way to get the HDD the exact size like 500 Gb or 80 Gb and so on...
Say the HDD is 500Gb i get hdd1 as 145+ and Hdd2 as 286+
Can i get them as HDD 1 and with a rounded no
ASKER
Thanks
Is there no way to get the HDD the exact size like 500 Gb or 80 Gb and so on...
Say the HDD is 500Gb i get hdd1 as 145+ and Hdd2 as 286+
Can i get them as HDD 1 and with a rounded no
Is there no way to get the HDD the exact size like 500 Gb or 80 Gb and so on...
Say the HDD is 500Gb i get hdd1 as 145+ and Hdd2 as 286+
Can i get them as HDD 1 and with a rounded no
I think what you want is this:
isize = Application.WorksheetFunct ion.Ceilin g(objItem. Size / 1024 / 1024 / 1024, 100)
This will round any number up to the next highest hundred.
That can result in some significant rounding, though. It will round 500.01Gb up to 600Gb. That can be very misleading.
Rounding it DOWN to the nearest hundred could produce a drive of size= 0Gb. I'm not sure which way you should go.
isize = Application.WorksheetFunct
This will round any number up to the next highest hundred.
That can result in some significant rounding, though. It will round 500.01Gb up to 600Gb. That can be very misleading.
Rounding it DOWN to the nearest hundred could produce a drive of size= 0Gb. I'm not sure which way you should go.
Sub Get_Configuration_Remote()
'Get the Configuration of a machine Processor,Ram,CDD,FDD,HDD
'Direct Machine
Application.DisplayAlerts = False
Dim objWMI
Dim lngRow As Long, lngRowCount As Long
lngRowCount = Cells(65536, "Q").End(xlUp).Row
'assumes header in row 1
For lngRow = 2 To lngRowCount
If (Cells(lngRow, "W").Value = "Could not be contacted." Or Cells(lngRow, "W").Value = "") And Cells(lngRow, "Q").Value <> "" Then
intHDD1 = 0
intHDD2 = 0
strPC = Cells(lngRow, "Q")
On Error Resume Next
Set objWMI = GetObject("winmgmts:\\" & strPC & "\root\CIMV2")
If Err.Number = 0 Then
Set colItems = objWMI.ExecQuery("Select * From Win32_Processor")
For Each objItem In colItems
strProcessor = Trim(Replace(Replace(objItem.Name, "Intel", ""), "(R)", ""))
Next objItem
Set colItems = objWMI.ExecQuery("Select * From Win32_OperatingSystem")
For Each objItem In colItems
strRAM = returnRAM(objItem.TotalVisibleMemorySize)
Next objItem
Set colItems = objWMI.ExecQuery("Select * From Win32_LogicalDisk")
For Each objItem In colItems
If Not IsNull(objItem.Size) Then
isize = Application.WorksheetFunction.Ceiling(objItem.Size / 1024 / 1024 / 1024, 100)
If UCase(objItem.DeviceID) = "C:" Or UCase(objItem.DeviceID) = "D:" Then
intHDD1 = FormatNumber(intHDD1 + isize, 0)
ElseIf UCase(objItem.DeviceID) = "E:" Or UCase(objItem.DeviceID) = "F:" Then
intHDD2 = FormatNumber(intHDD2 + isize, 0)
End If
End If
Next objItem
intHDD1 = intHDD1 & "Gb"
If intHDD2 > 0 Then
intHDD2 = intHDD2 & "Gb"
Else
intHDD2 = ""
End If
Set colItems = objWMI.ExecQuery("Select * from Win32_FloppyDrive")
If colItems.Count = 0 Then
strFloppy = ""
Else
strFloppy = "FDD"
End If
Set colItems = objWMI.ExecQuery("Select * from Win32_CDROMDrive")
If colItems.Count = 0 Then
strCD = ""
Else
strCD = "CDD"
End If
Set colItems = objWMI.ExecQuery("Select * From Win32_NetworkAdapter")
If colItems.Count > 0 Then
End If
With Cells(lngRow, "W")
.Value = strProcessor
.Offset(0, 1).Value = strRAM
.Offset(0, 2).Value = intHDD1
.Offset(0, 3).Value = intHDD2
.Offset(0, 4).Value = strFloppy
.Offset(0, 5).Value = strCD
End With
Else
Cells(lngRow, "W").Value = "Could not be contacted."
On Error GoTo 0
End If ' Err.Number = 0
Set objWMI = Nothing
End If
Next lngRow
Set objWMI = Nothing
Application.DisplayAlerts = True
End Sub
Function returnASize(rawsize As Double, Optional steps As Variant) As String
Dim sz As Double
Dim potentialSize As Variant
Dim arrOffset
returnASize = rawsize
sz = returnASize
If returnASize = "0" Then returnASize = 0
If Not IsMissing(steps) Then
returnASize = 0
For arrOffset = 0 To UBound(steps)
If sz > steps(arrOffset) Then
returnASize = CStr(steps(arrOffset - 1))
Exit For
End If
Next
End If
End Function
Function CBMod(Dividend, Divisor) As Integer
CBMod = Dividend - (Left(Dividend / Divisor & ".", InStr(Dividend / Divisor & ".", ".") - 1) * Divisor)
End Function
Function returnsize(dblSize As Double) As Variant
Dim cbBytes As Integer
Dim cbkilo As Integer
Dim cbMega As Integer
Dim cbGiga As Integer
Dim cbTera As Integer
Dim sizes(0 To 5) As Double
Dim looper As Integer
Dim Kbs() As Variant
Kbs = Array(1024, 768, 640, 512, 384, 256, 128, 0)
Dim minima() As Variant
minima = Array(1024, 0)
Dim halfSplit() As Variant
halfSplit = Array(1024, 512, 0)
sizes(0) = dblSize
For looper = 1 To 5
sizes(looper) = CBMod(sizes(0), 1024)
sizes(0) = (sizes(0) - sizes(looper)) / 1024
Next
sizes(0) = dblSize
returnsize = sizes
End Function
Function returnRAM(sz As Double) As String
Dim memSize() As Double
Dim gbMem As String
Dim halfSplit() As Variant
halfSplit = Array(1024, 512, 0)
memSize = returnsize(1024 * sz)
memSize(3) = returnASize(memSize(3), halfSplit)
returnRAM = memSize(4) + (memSize(3) / (2 ^ 10)) & "Gb"
End Function
ASKER
My main issue would be now. Is a 500 Gb HDD gets splitted as 2 HDD
HDDD1 & HDD2 why is this.
Cant i get then into HDD1 as its a single HDD
HDDD1 & HDD2 why is this.
Cant i get then into HDD1 as its a single HDD
ASKER
My main issue would be now. Is a 500 Gb HDD gets splitted as 2 HDD
HDDD1 & HDD2 why is this.
Cant i get then into HDD1 as its a single HDD
HDDD1 & HDD2 why is this.
Cant i get then into HDD1 as its a single HDD
Where did this macro come from? I notice there is some logic that groups C and D drives together, and also E and F.
isize = Application.WorksheetFunct ion.Ceilin g(objItem. Size / 1024 / 1024 / 1024, 100)
If UCase(objItem.DeviceID) = "C:" Or UCase(objItem.DeviceID) = "D:" Then
intHDD1 = FormatNumber(intHDD1 + isize, 0)
ElseIf UCase(objItem.DeviceID) = "E:" Or UCase(objItem.DeviceID) = "F:" Then
intHDD2 = FormatNumber(intHDD2 + isize, 0)
End If
I am not exactly sure why it would be doing this.
Can you post an example of the worksheet you see AFTER this macro runs? .. accompany that with a brief description of what your actual disk sizes are..
This is getting a little far from the original question. You might want to open a new question using a more specific subject line.
Brian Withun
isize = Application.WorksheetFunct
If UCase(objItem.DeviceID) = "C:" Or UCase(objItem.DeviceID) = "D:" Then
intHDD1 = FormatNumber(intHDD1 + isize, 0)
ElseIf UCase(objItem.DeviceID) = "E:" Or UCase(objItem.DeviceID) = "F:" Then
intHDD2 = FormatNumber(intHDD2 + isize, 0)
End If
I am not exactly sure why it would be doing this.
Can you post an example of the worksheet you see AFTER this macro runs? .. accompany that with a brief description of what your actual disk sizes are..
This is getting a little far from the original question. You might want to open a new question using a more specific subject line.
Brian Withun
ASKER
Ok can 1 change be done. Any no of drives if within 1 specific HDD then total all and place in HDD1 if only there is a secound HDD then put in HDD2
By this i guess the problem will resolve
By this i guess the problem will resolve
ASKER
Ok can 1 change be done. Any no of drives if within 1 specific HDD then total all and place in HDD1 if only there is a secound HDD then put in HDD2
By this i guess the problem will resolve
By this i guess the problem will resolve
ASKER
Hi any help on this
Sharath, so it looks like the cells that get filled in are columns W to AB, is that right?
What are the heading on those columns? What do you expect to see in each column?
Rob.
What are the heading on those columns? What do you expect to see in each column?
Rob.
ASKER
Thanks Rob...
yes its from A to AB
Processor Ram Hdd1 Hdd 2 Floppy Cd
Just for HDD1 and HDD2 i want the exact size of the HDD. Now what happens is if its a 80 GB HDD i get
HDD1 HDD2
42.3 34.8
So many different sizes i get for 40/80/120/160/500 GB HDD
I want the sizes to be exact
If 1 HDD get the total size in HDD1 and if its 2 HDD's then get them in HDD1 & HDD2
yes its from A to AB
Processor Ram Hdd1 Hdd 2 Floppy Cd
Just for HDD1 and HDD2 i want the exact size of the HDD. Now what happens is if its a 80 GB HDD i get
HDD1 HDD2
42.3 34.8
So many different sizes i get for 40/80/120/160/500 GB HDD
I want the sizes to be exact
If 1 HDD get the total size in HDD1 and if its 2 HDD's then get them in HDD1 & HDD2
ASKER
Thanks Rob...
yes its from A to AB
Processor Ram Hdd1 Hdd 2 Floppy Cd
Just for HDD1 and HDD2 i want the exact size of the HDD. Now what happens is if its a 80 GB HDD i get
HDD1 HDD2
42.3 34.8
So many different sizes i get for 40/80/120/160/500 GB HDD
I want the sizes to be exact
If 1 HDD get the total size in HDD1 and if its 2 HDD's then get them in HDD1 & HDD2
yes its from A to AB
Processor Ram Hdd1 Hdd 2 Floppy Cd
Just for HDD1 and HDD2 i want the exact size of the HDD. Now what happens is if its a 80 GB HDD i get
HDD1 HDD2
42.3 34.8
So many different sizes i get for 40/80/120/160/500 GB HDD
I want the sizes to be exact
If 1 HDD get the total size in HDD1 and if its 2 HDD's then get them in HDD1 & HDD2
ASKER
Hi Rob any views...
Hi, what does this give you?
Regards,
Rob.
Regards,
Rob.
Sub Get_Configuration_Remote()
'Get the Configuration of a machine Processor,Ram,CDD,FDD,HDD
'Direct Machine
Application.DisplayAlerts = False
Dim objWMI
Dim lngRow As Long, lngRowCount As Long
lngRowCount = Cells(65536, "Q").End(xlUp).Row
'assumes header in row 1
For lngRow = 2 To lngRowCount
If (Cells(lngRow, "W").Value = "Could not be contacted." Or Cells(lngRow, "W").Value = "") And Cells(lngRow, "Q").Value <> "" Then
intHDD1 = 0
intHDD2 = 0
strPC = Cells(lngRow, "Q")
On Error Resume Next
Set objWMI = GetObject("winmgmts:\\" & strPC & "\root\CIMV2")
If Err.Number = 0 Then
Set colItems = objWMI.ExecQuery("Select * From Win32_Processor")
For Each objItem In colItems
strProcessor = Trim(Replace(Replace(objItem.Name, "Intel", ""), "(R)", ""))
Next objItem
Set colItems = objWMI.ExecQuery("Select * From Win32_OperatingSystem")
For Each objItem In colItems
strRAM = returnRAM(objItem.TotalVisibleMemorySize)
Next objItem
Set colItems = objWMI.ExecQuery("Select * From Win32_LogicalDisk Where DriveType=3")
For Each objItem In colItems
If Not IsNull(objItem.Size) Then
isize = objItem.Size / 1024 / 1024 / 1024
If intHDD1 = 0 Then
intHDD1 = FormatNumber(intHDD1 + isize, 2)
Else
intHDD2 = FormatNumber(intHDD2 + isize, 2)
End If
End If
Next objItem
intHDD1 = intHDD1 & "Gb"
If intHDD2 > 0 Then
intHDD2 = intHDD2 & "Gb"
Else
intHDD2 = ""
End If
Set colItems = objWMI.ExecQuery("Select * from Win32_FloppyDrive")
If colItems.Count = 0 Then
strFloppy = ""
Else
strFloppy = "FDD"
End If
Set colItems = objWMI.ExecQuery("Select * from Win32_CDROMDrive")
If colItems.Count = 0 Then
strCD = ""
Else
strCD = "CDD"
End If
With Cells(lngRow, "W")
.Value = strProcessor
.Offset(0, 1).Value = strRAM
.Offset(0, 2).Value = intHDD1
.Offset(0, 3).Value = intHDD2
.Offset(0, 4).Value = strFloppy
.Offset(0, 5).Value = strCD
End With
Else
Cells(lngRow, "W").Value = "Could not be contacted."
On Error GoTo 0
End If ' Err.Number = 0
Set objWMI = Nothing
End If
Next lngRow
Set objWMI = Nothing
Application.DisplayAlerts = True
End Sub
Function returnASize(rawsize As Double, Optional steps As Variant) As String
Dim sz As Double
Dim potentialSize As Variant
Dim arrOffset
returnASize = rawsize
sz = returnASize
If returnASize = "0" Then returnASize = 0
If Not IsMissing(steps) Then
returnASize = 0
For arrOffset = 0 To UBound(steps)
If sz > steps(arrOffset) Then
returnASize = CStr(steps(arrOffset - 1))
Exit For
End If
Next
End If
End Function
Function CBMod(Dividend, Divisor) As Integer
CBMod = Dividend - (Left(Dividend / Divisor & ".", InStr(Dividend / Divisor & ".", ".") - 1) * Divisor)
End Function
Function returnsize(dblSize As Double) As Variant
Dim cbBytes As Integer
Dim cbkilo As Integer
Dim cbMega As Integer
Dim cbGiga As Integer
Dim cbTera As Integer
Dim sizes(0 To 5) As Double
Dim looper As Integer
Dim Kbs() As Variant
Kbs = Array(1024, 768, 640, 512, 384, 256, 128, 0)
Dim minima() As Variant
minima = Array(1024, 0)
Dim halfSplit() As Variant
halfSplit = Array(1024, 512, 0)
sizes(0) = dblSize
For looper = 1 To 5
sizes(looper) = CBMod(sizes(0), 1024)
sizes(0) = (sizes(0) - sizes(looper)) / 1024
Next
sizes(0) = dblSize
returnsize = sizes
End Function
Function returnRAM(sz As Double) As String
Dim memSize() As Double
Dim gbMem As String
Dim halfSplit() As Variant
halfSplit = Array(1024, 512, 0)
memSize = returnsize(1024 * sz)
memSize(3) = returnASize(memSize(3), halfSplit)
returnRAM = memSize(4) + (memSize(3) / (2 ^ 10)) & "Gb"
End Function
ASKER
Rob i get data as this
Core(TM)2 Duo CPU E4500 @ 2.20GHz 1Gb 29.29Gb 436.47Gb
But its a 500GB HDD it has only 1 HDD but shows in HDD1 and HDD2 colum Y & Z
Core(TM)2 Duo CPU E4500 @ 2.20GHz 1Gb 29.29Gb 436.47Gb
But its a 500GB HDD it has only 1 HDD but shows in HDD1 and HDD2 colum Y & Z
Oh, so you want entire disk size, not partition size. In that case, instead of querying Win32_LogicalDisk, we should query Win32_DiskDrive.
Regards,
Rob.
Regards,
Rob.
Sub Get_Configuration_Remote()
'Get the Configuration of a machine Processor,Ram,CDD,FDD,HDD
'Direct Machine
Application.DisplayAlerts = False
Dim objWMI
Dim lngRow As Long, lngRowCount As Long
lngRowCount = Cells(65536, "Q").End(xlUp).Row
'assumes header in row 1
For lngRow = 2 To lngRowCount
If (Cells(lngRow, "W").Value = "Could not be contacted." Or Cells(lngRow, "W").Value = "") And Cells(lngRow, "Q").Value <> "" Then
intHDD1 = 0
intHDD2 = 0
strPC = Cells(lngRow, "Q")
On Error Resume Next
Set objWMI = GetObject("winmgmts:\\" & strPC & "\root\CIMV2")
If Err.Number = 0 Then
Set colItems = objWMI.ExecQuery("Select * From Win32_Processor")
For Each objItem In colItems
strProcessor = Trim(Replace(Replace(objItem.Name, "Intel", ""), "(R)", ""))
Next objItem
Set colItems = objWMI.ExecQuery("Select * From Win32_OperatingSystem")
For Each objItem In colItems
strRAM = returnRAM(objItem.TotalVisibleMemorySize)
Next objItem
'Set colItems = objWMI.ExecQuery("Select * From Win32_LogicalDisk Where DriveType=3")
Set colItems = objWMI.ExecQuery("Select * From Win32_DiskDrive")
For Each objItem In colItems
If Not IsNull(objItem.Size) Then
isize = objItem.Size / 1024 / 1024 / 1024
If intHDD1 = 0 Then
intHDD1 = FormatNumber(intHDD1 + isize, 2)
Else
intHDD2 = FormatNumber(intHDD2 + isize, 2)
End If
End If
Next objItem
intHDD1 = intHDD1 & "Gb"
If intHDD2 > 0 Then
intHDD2 = intHDD2 & "Gb"
Else
intHDD2 = ""
End If
Set colItems = objWMI.ExecQuery("Select * from Win32_FloppyDrive")
If colItems.Count = 0 Then
strFloppy = ""
Else
strFloppy = "FDD"
End If
Set colItems = objWMI.ExecQuery("Select * from Win32_CDROMDrive")
If colItems.Count = 0 Then
strCD = ""
Else
strCD = "CDD"
End If
With Cells(lngRow, "W")
.Value = strProcessor
.Offset(0, 1).Value = strRAM
.Offset(0, 2).Value = intHDD1
.Offset(0, 3).Value = intHDD2
.Offset(0, 4).Value = strFloppy
.Offset(0, 5).Value = strCD
End With
Else
Cells(lngRow, "W").Value = "Could not be contacted."
On Error GoTo 0
End If ' Err.Number = 0
Set objWMI = Nothing
End If
Next lngRow
Set objWMI = Nothing
Application.DisplayAlerts = True
End Sub
Function returnASize(rawsize As Double, Optional steps As Variant) As String
Dim sz As Double
Dim potentialSize As Variant
Dim arrOffset
returnASize = rawsize
sz = returnASize
If returnASize = "0" Then returnASize = 0
If Not IsMissing(steps) Then
returnASize = 0
For arrOffset = 0 To UBound(steps)
If sz > steps(arrOffset) Then
returnASize = CStr(steps(arrOffset - 1))
Exit For
End If
Next
End If
End Function
Function CBMod(Dividend, Divisor) As Integer
CBMod = Dividend - (Left(Dividend / Divisor & ".", InStr(Dividend / Divisor & ".", ".") - 1) * Divisor)
End Function
Function returnsize(dblSize As Double) As Variant
Dim cbBytes As Integer
Dim cbkilo As Integer
Dim cbMega As Integer
Dim cbGiga As Integer
Dim cbTera As Integer
Dim sizes(0 To 5) As Double
Dim looper As Integer
Dim Kbs() As Variant
Kbs = Array(1024, 768, 640, 512, 384, 256, 128, 0)
Dim minima() As Variant
minima = Array(1024, 0)
Dim halfSplit() As Variant
halfSplit = Array(1024, 512, 0)
sizes(0) = dblSize
For looper = 1 To 5
sizes(looper) = CBMod(sizes(0), 1024)
sizes(0) = (sizes(0) - sizes(looper)) / 1024
Next
sizes(0) = dblSize
returnsize = sizes
End Function
Function returnRAM(sz As Double) As String
Dim memSize() As Double
Dim gbMem As String
Dim halfSplit() As Variant
halfSplit = Array(1024, 512, 0)
memSize = returnsize(1024 * sz)
memSize(3) = returnASize(memSize(3), halfSplit)
returnRAM = memSize(4) + (memSize(3) / (2 ^ 10)) & "Gb"
End Function
ASKER
Rob now its better ...Can i get a round figure
I get as this
465.76Gb
74.54Gb
149.05Gb
I get as this
465.76Gb
74.54Gb
149.05Gb
ASKER
Rob now its better ...Can i get a round figure
I get as this
465.76Gb
74.54Gb
149.05Gb
I get as this
465.76Gb
74.54Gb
149.05Gb
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I get like this
465Gb. Actuall the size is 500 GB
74Gb Actuall the size is 80 GB
149Gb Actuall the size is 160 GB
Can i not get the total HDD size
465Gb. Actuall the size is 500 GB
74Gb Actuall the size is 80 GB
149Gb Actuall the size is 160 GB
Can i not get the total HDD size
ASKER
I get like this
465Gb. Actuall the size is 500 GB
74Gb Actuall the size is 80 GB
149Gb Actuall the size is 160 GB
Can i not get the total HDD size
465Gb. Actuall the size is 500 GB
74Gb Actuall the size is 80 GB
149Gb Actuall the size is 160 GB
Can i not get the total HDD size
Hmmm, I think that's the difference between how Windows calculates size and how DOS calculates size. I'm pretty sure that (stupidly enough) Windows calculates it at 1000KB per Megabyte.
Change this line:
isize = objItem.Size / 1024 / 1024 / 1024
to this
isize = objItem.Size / 1000 / 1000 / 1000
Regards,
Rob.
Change this line:
isize = objItem.Size / 1024 / 1024 / 1024
to this
isize = objItem.Size / 1000 / 1000 / 1000
Regards,
Rob.
ASKER
Perfect Rob works exact...
If you remember for the Ram check post you gave me an option of the cells being colored when there is a change. Can you help with this code also.
I shall post a new Q if you say so...
Color cells when there is a change....
If you remember for the Ram check post you gave me an option of the cells being colored when there is a change. Can you help with this code also.
I shall post a new Q if you say so...
Color cells when there is a change....
ASKER
Perfect Rob works exact...
If you remember for the Ram check post you gave me an option of the cells being colored when there is a change. Can you help with this code also.
I shall post a new Q if you say so...
Color cells when there is a change....
If you remember for the Ram check post you gave me an option of the cells being colored when there is a change. Can you help with this code also.
I shall post a new Q if you say so...
Color cells when there is a change....
Yeah, that can be done if you like. Let me know the URL to the new Q and I'll check it out...probably tomorrow....
Regards,
Rob.
Regards,
Rob.
ASKER
ASKER
ASKER
Rob i have few issues here with this code..
For machines that have 80 GB HDD i get
81Gb & 82Gb and for some 160 Gb as the size. Which is wrong
The code does not check for Cd drives....
For machines that have 80 GB HDD i get
81Gb & 82Gb and for some 160 Gb as the size. Which is wrong
The code does not check for Cd drives....
ASKER
Hi Rob,,,
When the machine is Offline i want the old data to stay intact but just change the color to red...
if there is a change. then append the change and color yellow.
The 2nd part is correct just the offline part has to be changed.
Can you please... help with the change.....
When the machine is Offline i want the old data to stay intact but just change the color to red...
if there is a change. then append the change and color yellow.
The 2nd part is correct just the offline part has to be changed.
Can you please... help with the change.....
from
isize = objItem.Size / 1024 / 1024 / 1024
to
isize = Round(objItem.Size / 1024 / 1024 / 1024, 0)
from
"53.92Gb"
to
"54Gb"
Open in new window