Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 109
Default Help with some code please

This is what I want this particular piece of code to do:

Check column B, if the value in column B is 1 then check column's K and L to
see if either of them have an entry in them. If there is an entry in
either, or both, and column F does not contain 'No' then display a msgbox
with the value of column C in it.

This is what I have so far, I am am stuck on the And Or bits:

Sub Check()
Application.ScreenUpdating = False
With Worksheets("Sheet1")
Set rng = .Range("B2:B" & .Range("B" & Rows.Count).End(xlUp).Row)
End With
For Each cell In rng
If cell.Value = 1 And .......Or ......And ......Then
MsgBox "Please check " & cell.Offset(0,1).Value
End If
Next cell
Application.ScreenUpdating = True
End Sub

Thanks in advance.

Gareth


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 107
Default Help with some code please

Sub Check()
Dim rng As Range
Dim cell As Range

With Worksheets("Sheet1")
Set rng = .Range("B2:B" & .Range("B65536").End(xlUp).Row)
End With

For Each cell In rng
With cell
If .Value = 1 And .Offset(0, 4) < "No" _
And (.Offset(0, 9).Value < "" Or .Offset(0, 10).Value < "")
Then
MsgBox "Please check " & .Offset(0, 1).Value
End If
End With
Next cell
End Sub

(I declared the variables, since I use Option Explicit.)

Note that this does not handle the situation where the value in B, F, K
or L are errors. Some additional code would be required to check for
this (or On Error Resume Next, I guess).

--
HTH,
Dianne

In ,
Gareth typed:
This is what I want this particular piece of code to do:

Check column B, if the value in column B is 1 then check column's K
and L to see if either of them have an entry in them. If there is an
entry in either, or both, and column F does not contain 'No' then
display a msgbox with the value of column C in it.

This is what I have so far, I am am stuck on the And Or bits:

Sub Check()
Application.ScreenUpdating = False
With Worksheets("Sheet1")
Set rng = .Range("B2:B" & .Range("B" & Rows.Count).End(xlUp).Row)
End With
For Each cell In rng
If cell.Value = 1 And .......Or ......And ......Then
MsgBox "Please check " & cell.Offset(0,1).Value
End If
Next cell
Application.ScreenUpdating = True
End Sub

Thanks in advance.

Gareth



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
split post code (zip code) out of cell that includes full address Concord Excel Discussion (Misc queries) 4 October 15th 09 06:59 PM
Code to conditional format all black after date specified in code? wx4usa Excel Discussion (Misc queries) 3 December 26th 08 07:06 PM
Drop Down/List w/Code and Definition, only code entered when selec Spiritdancer Excel Worksheet Functions 2 November 2nd 07 03:57 AM
Convert a Number Code to a Text Code Traye Excel Discussion (Misc queries) 3 April 6th 07 09:54 PM
copying vba code to a standard code module 1vagrowr Excel Discussion (Misc queries) 2 November 23rd 05 04:00 PM


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