LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ray Ray is offline
external usenet poster
 
Posts: 267
Default Loop code, capture exceptions, and display pop-up

Hello -

I've built some code to pull in data from Workbooks submitted by my
stores. These workbooks have been in use for some time and several
'versions' have been released, with some format differences (ie data
in different cells). For this reason, it's important that workbooks
NOT in the correct version be 'rejected'. The code below skips these
workbooks, but I'd like to have the code capture these exceptions and
display a pop-up box at the end of the loop to tell the user which
workbooks have been skipped.

The pop-up should say something like:
"The following workbooks were not imported" .. and then list the
stores (values of 'getstore') one below the other. So, like this:
100
101
102
rather than
100 101 102

Can you help to modify my code to do this?

TIA,
Ray


The 'meat' of the code (assume all variables are properly defined):

If Fnum 0 Then
For Fnum = LBound(MyFiles) To UBound(MyFiles)
Set mybook = Workbooks.Open(MyPath & MyFiles(Fnum), 0,
True)

Application.StatusBar = "Now processing File " & Fnum & "
of " & total

' Isolates the store number from the workbook name
getstore = mybook.Sheets("Dashboard").Range("E13").Value
getstore = Format(getstore, "000")
getversion = mybook.Sheets("Dashboard").Range("K2").Value
If getstore < "259" And getversion = "v5.0" Then

Set myC = basebook.Worksheets("DATA"). _
Range("e4:an4").Find(getstore, LookIn:=xlValues,
LookAt:=xlWhole)

If Not myC Is Nothing Then
Tcol = myC.Column
Else
MsgBox getstore & " wasn't found"
'Ot"her action to take when getstore is not
found
End If



basebook.Sheets("DATA").Activate

ActiveSheet.Range("A1").Offset(4, Tcol - 1).Value =
mybook.Sheets("Exec Summary").Range("N29").Value
ActiveSheet.Range("A1").Offset(5, Tcol - 1).Value =
mybook.Sheets("GPR").Range("T21").Value +
mybook.Sheets("GPR").Range("T22").Value
ActiveSheet.Range("A1").Offset(5, Tcol - 1).Value =
ActiveSheet.Range("A1").Offset(5, Tcol - 1).Value /
ActiveSheet.Range("A1").Offset(4, Tcol - 1).Value
ActiveSheet.Range("A1").Offset(6, Tcol - 1).Value =
mybook.Sheets("Exec Summary").Range("P44").Value
ActiveSheet.Range("A1").Offset(7, Tcol - 1).Value =
mybook.Sheets("Exec Summary").Range("N39").Value
ActiveSheet.Range("A1").Offset(8, Tcol - 1).Value =
mybook.Sheets("P&L Acct Detail").Range("W381").Value
ActiveSheet.Range("A1").Offset(9, Tcol - 1).Value =
mybook.Sheets("Exec Summary").Range("P22").Value * -1

ActiveSheet.Range("A1").Offset(0, Tcol - 1).Value =
mybook.Sheets("Dashboard").Range("K2").Value

mybook.Close savechanges:=False
End If
Next Fnum
End If
 
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 screen capture to capture cells and row and column headings jayray Excel Discussion (Misc queries) 5 November 2nd 07 11:01 PM
Add Loop to code Alex Excel Programming 1 November 28th 06 03:51 PM
RTD and Exceptions Adam Excel Programming 0 March 12th 06 11:46 PM
Capture first 2 letters from a product code stumped Excel Worksheet Functions 2 May 18th 05 07:19 PM
For Each Loop with Exceptions ExcelMonkey[_190_] Excel Programming 3 February 10th 05 12:34 PM


All times are GMT +1. The time now is 06:12 PM.

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"