Report file size from file paths specified in cell - wildcards

choughton

New Member
Joined
Jun 18, 2019
Messages
2
Hi,

I have a rather specific query i need help with.

I have a spreadsheet which has a series of cell values that relate to daily files we receive from around the business.

As part of a wider process i run a series of macros to copy and move these files from their source folders.

I would now like to report the sizes of these files as a control check to flag files that are empty, but i'm having trouble doing this for files where i don't always know their full name - e.g. where the file name contains a time stamp.

Example file paths:

File pathFile size KB
\\DocDirect_File1_detail\HOLD folder\ND_730NA_20190618.csv66879
\\Source files\OWN BRANDS\OB_I2AR_FILE_1_20190617.csv152
\\Source files\OWN BRANDS\Cardnet Chargebacks\Chargebacks * 20190616.csv

<tbody>
</tbody>


So for the first 2 file paths listed above, i know the exact file name, but the third file path (the 'Chargebacks' file) there is a unique report reference in the file name i don't know so i use a wild card (*) to pick up the file and move it, which works fine, but i can't seem to report on the file size using the additional code i've written, whereas i can for the other 2.

The code i've written specifically to report on the file size is as follows (bear in mind there are about 50 files so i use a loop to search through them all). I know the issue is to do with using the 'File Item' as a String, as it's not the exact file name, so what should i use instead? Any suggestions?:

Sub Test()


Dim FileItem As String

Range("C$2").Select
Do While ActiveCell.Address <> "$C$49"
ActiveCell.Offset(1, 0).Select

If ActiveCell.Value = "" Then
ActiveCell.Offset(0, 1).Value = ""

Else
On Error Resume Next
FileItem = ActiveCell.Value

ActiveCell.Offset(0, 1).Formula = Round((FileLen(FileItem) / 1024) + 0.5)


End If

Loop

Application.ScreenUpdating = True
End Sub
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying

Forum statistics

Threads
1,214,643
Messages
6,120,702
Members
448,980
Latest member
CarlosWin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top