Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 64
Default End sub routine, move to next

I am new to VBA, but have been able to do some automation in a workbook
partially by recording a macro, by research, and a few questions to this
website. Almost finished, but I need a little more help.

On a worksheet in my workbook, I have a variable range, which, once found, I
have a total put into Column L. The range is then copied and pasted into
another workbook. However, if the total in Column L is 0.00, I need to skip
the rest of the routine and move to the next sub routine called CopyCosts.
Following is part of the sub routine I am working with:

Range("H1:h45").Select
Selection.Find(What:=" ", After:=ActiveCell, LookIn:=xlValues, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:=False _
, SearchFormat:=False).Activate

ActiveCell.Offset(0, 4).Select
ActiveCell.Offset(-1, 0).Select
ActiveCell.Value = Application.Sum([d2:d46])

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

Sheets("Input").Select
Workbooks.Open Filename:="G:\" & Range("A1").Value & "\BD"

What statement would be used so that if Application.Sum([d2:d46]) = 0.00,
end, then go to next sub?

Thanks
--
Linda
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 130
Default End sub routine, move to next

Linda,

Use the IF command:

If Application.Sum("D2:D46") = 0 Then
call CopyCosts
End
Else
' Do something
End if

HTH,
Matthew Pfluger

"mathel" wrote:

I am new to VBA, but have been able to do some automation in a workbook
partially by recording a macro, by research, and a few questions to this
website. Almost finished, but I need a little more help.

On a worksheet in my workbook, I have a variable range, which, once found, I
have a total put into Column L. The range is then copied and pasted into
another workbook. However, if the total in Column L is 0.00, I need to skip
the rest of the routine and move to the next sub routine called CopyCosts.
Following is part of the sub routine I am working with:

Range("H1:h45").Select
Selection.Find(What:=" ", After:=ActiveCell, LookIn:=xlValues, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:=False _
, SearchFormat:=False).Activate

ActiveCell.Offset(0, 4).Select
ActiveCell.Offset(-1, 0).Select
ActiveCell.Value = Application.Sum([d2:d46])

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

Sheets("Input").Select
Workbooks.Open Filename:="G:\" & Range("A1").Value & "\BD"

What statement would be used so that if Application.Sum([d2:d46]) = 0.00,
end, then go to next sub?

Thanks
--
Linda

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 64
Default End sub routine, move to next

I've tried what you wrote below. I'm getting the following error code:
"Run-time error '13' Type mismatch

The VB Editor is highlighting: If Application.Sum ("d2:d46") = 0 Then

Any ideas?

--
Linda


"Matthew Pfluger" wrote:

Linda,

Use the IF command:

If Application.Sum("D2:D46") = 0 Then
call CopyCosts
End
Else
' Do something
End if

HTH,
Matthew Pfluger

"mathel" wrote:

I am new to VBA, but have been able to do some automation in a workbook
partially by recording a macro, by research, and a few questions to this
website. Almost finished, but I need a little more help.

On a worksheet in my workbook, I have a variable range, which, once found, I
have a total put into Column L. The range is then copied and pasted into
another workbook. However, if the total in Column L is 0.00, I need to skip
the rest of the routine and move to the next sub routine called CopyCosts.
Following is part of the sub routine I am working with:

Range("H1:h45").Select
Selection.Find(What:=" ", After:=ActiveCell, LookIn:=xlValues, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:=False _
, SearchFormat:=False).Activate

ActiveCell.Offset(0, 4).Select
ActiveCell.Offset(-1, 0).Select
ActiveCell.Value = Application.Sum([d2:d46])

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

Sheets("Input").Select
Workbooks.Open Filename:="G:\" & Range("A1").Value & "\BD"

What statement would be used so that if Application.Sum([d2:d46]) = 0.00,
end, then go to next sub?

Thanks
--
Linda

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default End sub routine, move to next

If Application.Sum(worksheets("worksheetnamehere").ra nge("D2:D46")) = 0 Then



mathel wrote:

I've tried what you wrote below. I'm getting the following error code:
"Run-time error '13' Type mismatch

The VB Editor is highlighting: If Application.Sum ("d2:d46") = 0 Then

Any ideas?

--
Linda

"Matthew Pfluger" wrote:

Linda,

Use the IF command:

If Application.Sum("D2:D46") = 0 Then
call CopyCosts
End
Else
' Do something
End if

HTH,
Matthew Pfluger

"mathel" wrote:

I am new to VBA, but have been able to do some automation in a workbook
partially by recording a macro, by research, and a few questions to this
website. Almost finished, but I need a little more help.

On a worksheet in my workbook, I have a variable range, which, once found, I
have a total put into Column L. The range is then copied and pasted into
another workbook. However, if the total in Column L is 0.00, I need to skip
the rest of the routine and move to the next sub routine called CopyCosts.
Following is part of the sub routine I am working with:

Range("H1:h45").Select
Selection.Find(What:=" ", After:=ActiveCell, LookIn:=xlValues, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:=False _
, SearchFormat:=False).Activate

ActiveCell.Offset(0, 4).Select
ActiveCell.Offset(-1, 0).Select
ActiveCell.Value = Application.Sum([d2:d46])

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

Sheets("Input").Select
Workbooks.Open Filename:="G:\" & Range("A1").Value & "\BD"

What statement would be used so that if Application.Sum([d2:d46]) = 0.00,
end, then go to next sub?

Thanks
--
Linda


--

Dave Peterson
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
sub routine Gord Dibben Excel Discussion (Misc queries) 0 November 13th 09 12:15 AM
VBA routine (101) Ray Excel Programming 5 August 26th 05 08:02 PM
SUB ROUTINE tokirk Excel Programming 1 January 19th 04 02:17 AM
Routine?? Zax Excel Programming 3 December 19th 03 05:50 PM
Need VBA Routine John M. Lembo Excel Programming 0 July 13th 03 01:51 AM


All times are GMT +1. The time now is 05:40 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"