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 END IF in a macro

Hi,

I am working with Excel 2003 and have a problem with End If statement in a
macro. I have created a workbook named Agency Billing. What I need to do
is:

-if the sum of range D2:D46 = 0.00, then go to sub-routine called CopyCosts
-otherwise, copy specified range, open wb Bad Debt, find next blank row,
paste data, save & close Bad Debt wb, then

-go to sub-routine CopyCost
-if cell named exp = 0.00, the go to sub-routine to CloseFile, otherwise
-copy range named CopyCost, open wb Collection Cost, find next blank row,
paste data, save and close Collection Cost wb, then

-close active wb (Agency Billing) without saving.

What happens is if D2:D46 is greater than 0.00, it will run this routine,
but stops without going to the next sub-routine to CopyCosts. I have no
idea why it will not run and am hoping someone can help. A portion of the
macro I have is as follows:

If Application.Sum(Worksheets("Bad Debt").Range("D2:D46")) = 0 Then

Call CopyCost

Else
End If

Dim lastRow As Long
lastRow = Cells(Rows.Count, "l").End(xlUp).Row
'set variable to the last used row in L
Range("H1:L" & lastRow).Copy

Workbooks.Open Filename:="G:\Bad Debt"

Range("A5").Select
Do Until ActiveCell.Value = ""
ActiveCell.Offset(1, 0).Select
Loop

Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False

ActiveCell.Offset(1, 0).Select
ActiveWorkbook.Save
ActiveWindow.Close

End Sub

Sub CopyCost()

Application.Goto Reference:="exp"
If Worksheets("Input").Range("exp") = 0 Then

Call CloseFile
End
Else
End If

Application.Goto Reference:="CopyCost"
Selection.Copy

Workbooks.Open Filename:="G:\Collection Costs"
Range("A5").Select
Do Until ActiveCell.Value = ""
ActiveCell.Offset(1, 0).Select
Loop

Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ActiveCell.Offset(1, 0).Select
ActiveWorkbook.Save
ActiveWindow.Close

End Sub

Sub CloseFile()
Sheets("Input").Select
Range("A1").Select

MsgBox "Collection Costs & Bad Debt have been recorded. This file will
close now"
Application.ScreenUpdating = True

ActiveWorkbook.Close SaveChanges:=False

End Sub

Thanks
--
Linda
 
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 recorded... tabs & file names changed, macro hangs Steve Excel Worksheet Functions 3 October 30th 09 11:41 AM
Macro to copy and paste values (columns)I have a macro file built C02C04 Excel Programming 2 May 2nd 08 01:51 PM
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort Gavin Excel Worksheet Functions 0 May 17th 07 01:20 PM
macro to delete entire rows when column A is blank ...a quick macro vikram Excel Programming 4 May 3rd 04 08:45 PM
Start Macro / Stop Macro / Restart Macro Pete[_13_] Excel Programming 2 November 21st 03 05:04 PM


All times are GMT +1. The time now is 04:21 PM.

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"