Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 557
Default MACRO IS NOT COMPLETE

Hi , I want to add line in macro (please see below) that if I have
text of "ZERO
BUDGET"
appear in any cell of Range("K25:K62") then I should get
Message box appear that there is Zero budget. What should i put in
macro below that do the work which i mentioned above

Private Sub Worksheet_Change(ByVal Target As Range)
Dim MyRange As Range
Const WS_RANGE As String = "B25:D62"
On Error GoTo ws_exit
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
If Me.Cells(.Row, "B").Value < "" And _
Me.Cells(.Row, "C").Value < "" Then
If IsError(Application.Match(Me.Cells(.Row, "O").Value,
Columns(27), 0)) Then
MsgBox "NO BUDGET IN AGRESSO", vbInformation, "INFORMATION"


End If
End If
End With
End If
Set MyRange = Range("F25:F62")
If Target.Cells.Count = 1 Then
If Not Intersect(Target, Range("F25:F62")) Is Nothing Then
If IsNumeric(Target) Then
budget = WorksheetFunction.VLookup(Target.Offset(0, 9).Value,
Range("AB1:AC9995"), 2, False)
On Error Resume Next
For Each c In MyRange
If c.Address < Target.Address Then
If c.Offset(0, 9).Value = Target.Offset(0, 9).Value Then
budget = budget + c.Value
End If
End If
Next c
On Error GoTo ws_exit
If Target.Value < "" Then
Target.Offset(0, 5).Value = budget
Else
Target.Offset(0, 5).Value = ""
End If
End If
End If
End If
ws_exit:
Application.EnableEvents = True
End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 220
Default MACRO IS NOT COMPLETE

For Each cell In Range("K25:K62")
If cell.Text = "ZERO BUDGET" Then
MsgBox "Zero Budget", vbInformation
Exit For
End If
Next cell

--
Dan

On Jan 4, 3:16*pm, K wrote:
Hi , I want to add line in macro (please see below) that if I have
text of "ZERO
BUDGET"
appear in any cell of Range("K25:K62") then I should get
Message box appear that there is Zero budget. What should i put in
macro below that do the work which i mentioned above

Private Sub Worksheet_Change(ByVal Target As Range)
* Dim MyRange As Range
* Const WS_RANGE As String = "B25:D62"
* On Error GoTo ws_exit
* Application.EnableEvents = False
* If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
* * With Target
* * * If Me.Cells(.Row, "B").Value < "" And _
* * * * Me.Cells(.Row, "C").Value < "" Then
* * * * If IsError(Application.Match(Me.Cells(.Row, "O").Value,
Columns(27), 0)) Then
* * * * * MsgBox "NO BUDGET IN AGRESSO", vbInformation, "INFORMATION"

* * * * End If
* * * End If
* * End With
* End If
* Set MyRange = Range("F25:F62")
* If Target.Cells.Count = 1 Then
* * If Not Intersect(Target, Range("F25:F62")) Is Nothing Then
* * * If IsNumeric(Target) Then
* * * * budget = WorksheetFunction.VLookup(Target.Offset(0, 9).Value,
Range("AB1:AC9995"), 2, False)
* * * * On Error Resume Next
* * * * For Each c In MyRange
* * * * * If c.Address < Target.Address Then
* * * * * * If c.Offset(0, 9).Value = Target.Offset(0, 9).Value Then
* * * * * * * budget = budget + c.Value
* * * * * * End If
* * * * * End If
* * * * Next c
* * * * On Error GoTo ws_exit
* * * * If Target.Value < "" Then
* * * * * Target.Offset(0, 5).Value = budget
* * * * Else
* * * * * Target.Offset(0, 5).Value = ""
* * * * End If
* * * End If
* * End If
* End If
ws_exit:
* Application.EnableEvents = True
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default MACRO IS NOT COMPLETE

Here's another way.

If WorksheetFunction.CountIF(Range("K25:K62"),"ZERO BUDGET") 0 Then
MsgBox "I found Zero Budget in this range."
End if


HTH,
JP


"K" wrote in message
...
Hi , I want to add line in macro (please see below) that if I have
text of "ZERO
BUDGET"
appear in any cell of Range("K25:K62") then I should get
Message box appear that there is Zero budget. What should i put in
macro below that do the work which i mentioned above

Private Sub Worksheet_Change(ByVal Target As Range)
Dim MyRange As Range
Const WS_RANGE As String = "B25:D62"
On Error GoTo ws_exit
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
If Me.Cells(.Row, "B").Value < "" And _
Me.Cells(.Row, "C").Value < "" Then
If IsError(Application.Match(Me.Cells(.Row, "O").Value,
Columns(27), 0)) Then
MsgBox "NO BUDGET IN AGRESSO", vbInformation, "INFORMATION"


End If
End If
End With
End If
Set MyRange = Range("F25:F62")
If Target.Cells.Count = 1 Then
If Not Intersect(Target, Range("F25:F62")) Is Nothing Then
If IsNumeric(Target) Then
budget = WorksheetFunction.VLookup(Target.Offset(0, 9).Value,
Range("AB1:AC9995"), 2, False)
On Error Resume Next
For Each c In MyRange
If c.Address < Target.Address Then
If c.Offset(0, 9).Value = Target.Offset(0, 9).Value Then
budget = budget + c.Value
End If
End If
Next c
On Error GoTo ws_exit
If Target.Value < "" Then
Target.Offset(0, 5).Value = budget
Else
Target.Offset(0, 5).Value = ""
End If
End If
End If
End If
ws_exit:
Application.EnableEvents = True
End Sub




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
Macro wait 30 seconds then Complete the Macro Vick Excel Discussion (Misc queries) 2 June 2nd 08 08:04 PM
Inefficient macro won't complete Fox via OfficeKB.com Excel Programming 2 June 16th 06 08:42 PM
Please I need some help to complete a VBA Macro Francesco Excel Discussion (Misc queries) 7 April 11th 06 02:06 PM
Complete Newbe - Is this a MACRO function or VB ? Justin Excel Programming 6 July 26th 05 09:52 PM
macro to complete missing data lshavit Excel Programming 2 October 28th 04 06:38 PM


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