PC Review


Reply
Thread Tools Rate Thread

Directory Name - IF Named Range Exists

 
 
New Member
Join Date: Feb 2010
Posts: 2
 
      23rd Feb 2010
Hi All,

I need some serious help with this code! The goal is to loop through a group of files in a folder.. and have it return to me the names of files that contain a certain named range called "PullData". I have a loop macro that goes through the directory to pull file names... but I don't know how to make it first check for the named range. Please help! Also, does anyone know if this code will work in Excel 2003? I'm currently using 2007...

Sub CommandButton()

Application.ScreenUpdating = False

'Unhide Sheet11 (Formulas)
Sheet11.Visible = xlSheetVisible

Sheets("Formulas").Select
'PART 1: Loop File
'Turn off screen updating
'Application.ScreenUpdating = False

'File list
Dim Directory As String
Dim FileName As String
Dim IndexSheet As Worksheet
Dim row As Long
UserDir = Sheets("Formulas").Range("C2").Value

'Change the directory below as needed
Directory = UserDir
If Left(Directory, 1) <> "\" Then
Directory = Directory & "\"
End If

row = 11

Set IndexSheet = ThisWorkbook.ActiveSheet

FileName = Dir(Directory & "*.xls")
Do While FileName <> ""
IndexSheet.Cells(row, 2).Value = FileName
row = row + 1
FileName = Dir
Loop

Set IndexSheet = Nothing

'Go to MoveItems
MoveReplaceRenew

'Hide Sheet11
Sheet11.Visible = xlSheetVeryHidden
'Turn on screen updating
Application.ScreenUpdating = True



End Sub
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Check if a named range exists with VBA? mcolson1590@gmail.com Microsoft Excel Programming 3 31st Jan 2007 06:58 PM
Check if named range exists! =?Utf-8?B?c3RldmVfZG9j?= Microsoft Excel Programming 2 29th Apr 2006 11:56 PM
Determining if a named range exists a Microsoft Excel Programming 2 5th Jan 2006 01:39 PM
Validate Named Range Exists =?Utf-8?B?Sm9obiBKb3N0?= Microsoft Excel Programming 5 5th Dec 2005 08:17 PM
how to tell if a named range exists =?Utf-8?B?R2l4eGVyX0pfOTc=?= Microsoft Excel Programming 2 1st Jun 2005 07:38 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:14 AM.