LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 64
Default Stopping the "Next" command when a blank cell is reached.

Hi all,

I have the following that copies files from folders:-

----------------------
Sub copysomefiles()
On Error GoTo ErrorHandler
Dim sMess As String
Dim ans
sMess = "Have you entered your File Prefix (if required) and Destination
Filepath (3 & 4)?" & vbCrLf & vbCrLf & _
"Press Yes to confirm, or No to cancel"
ans = MsgBox(sMess, vbYesNo, "Copy Filenames")

If ans = vbYes Then
Dim fname As Range
For Each fname In Range("fileRange")
FileCopy Range("source") & fname, Range("destination") & Left(fname, 8) &
Range("prefix") & Right(fname, 4)

Next

Exit Sub
ErrorHandler:
If ans = vbNo Then Exit Sub
End If
End Sub
----------------

The range "fileRange" is basically the whole of column A, but there can be
any number of cells with data in them, and the rest of the range being blank
(i.e A1:A100 with data and A100:A65536 without data).

How can I get the next command to stop when its reaches a blank cell (i.e.
cell A101)?


Thanks,

Bhupinder



 
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
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
Stopping looped "Find" command Varne Excel Discussion (Misc queries) 3 September 24th 07 09:26 AM
can alarm be coded into a cell "x" hours before date's reached ? amblebookworm Excel Worksheet Functions 1 April 7th 07 01:00 PM
inserting a conditional "go to" command on a excel "if" function velasques Excel Worksheet Functions 5 March 10th 06 08:16 PM
Changing "returned" values from "0" to "blank" LATATC Excel Worksheet Functions 2 October 20th 05 04:41 PM


All times are GMT +1. The time now is 03:36 AM.

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

About Us

"It's about Microsoft Excel"