Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Excel macro help

I have an excel macro with the following code:

Sub ITEM_COUNT()
Range("c10").Select
Dim fso
Dim fol
Dim subfol
Set fso = CreateObject("Scripting.FileSystemObject")
Set fol = fso.getfolder("c:\" & Range("c10").Text)
Set subfol = fol.subfolders
sc = subfol.Count
With ActiveSheet
Range("c10").Offset(0, 3) = sc
End With

End Sub

This code takes what is written in cell C10(base folder name) and counts
the number of subfolders in it and places the count in cell F10. What I
would like to do now is do the same thing on the next rows(ie. C11, C12,
C13, etc...)and place the subfolder count in its respective cell in
column F.

Thanks, Martin

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default Excel macro help

Sub ITEM_COUNT()
Dim fso, fol
Dim Cell As Range
Set fso = CreateObject("Scripting.FileSystemObject")
For Each Cell In Range("C10:C20") ''Adjust as needed
Set fol = fso.getfolder("c:\" & Cell.Text)
Cell.Offset(0, 3) = fol.subfolders.Count
Next
End Sub


--
Jim Rech
Excel MVP
"Martin Lawrence" wrote in message
...
|I have an excel macro with the following code:
|
| Sub ITEM_COUNT()
| Range("c10").Select
| Dim fso
| Dim fol
| Dim subfol
| Set fso = CreateObject("Scripting.FileSystemObject")
| Set fol = fso.getfolder("c:\" & Range("c10").Text)
| Set subfol = fol.subfolders
| sc = subfol.Count
| With ActiveSheet
| Range("c10").Offset(0, 3) = sc
| End With
|
| End Sub
|
| This code takes what is written in cell C10(base folder name) and counts
| the number of subfolders in it and places the count in cell F10. What I
| would like to do now is do the same thing on the next rows(ie. C11, C12,
| C13, etc...)and place the subfolder count in its respective cell in
| column F.
|
| Thanks, Martin
|
| *** Sent via Developersdex http://www.developersdex.com ***
| Don't just participate in USENET...get rewarded for it!


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Excel macro help

Thanks for your reply, but now I have 2 more issues. First I need to
check to see if the folder actually exists Second, I would like the
macro to stop running when the first empty cell is reached in column C.

Martin

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort Gavin Excel Worksheet Functions 0 May 17th 07 01:20 PM
My excel macro recorder no longer shows up when recording macro jack Excel Discussion (Misc queries) 1 February 5th 07 09:31 PM
My excel macro recorder no longer shows up when recording macro jack Excel Discussion (Misc queries) 3 February 5th 07 08:22 PM
Excel Macro Issue Trying to autorun Macro Upon Opening Worksheet wyndman Excel Programming 2 May 25th 04 06:59 PM


All times are GMT +1. The time now is 10:13 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"