#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Lookup VBA

I have a workbook with 2 sheets.
I am looking for a short procedure that detects if there, in sheet 2, is any
occupied cell in column K (K4 and down) with no data in the cell to the right
(column I). Then a message should pop up saying: "Please update the sheet".

Any suggestions?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Lookup VBA

Sub FindMissing()
Dim k As Long, i As Long
With Sheets("Sheet2")
k = Cells(Rows.Count, "K").End(xlUp).Row
For i = 4 To k
If Cells(i, "K").Value < "" And Cells(i, "I").Value = "" Then
MsgBox "Please update the sheet"
End If
Next
End With
End Sub

--
Gary''s Student - gsnu201001


"tomjoe" wrote:

I have a workbook with 2 sheets.
I am looking for a short procedure that detects if there, in sheet 2, is any
occupied cell in column K (K4 and down) with no data in the cell to the right
(column I). Then a message should pop up saying: "Please update the sheet".

Any suggestions?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Lookup VBA

First off, you say you want to check the cell to the **right** of Column K (for being blank), but then you identify that column as Column I... Column I is two columns to the **left** of Column K, not one cell to the right. I'm guessing you meant to type Column L and mistakenly typed I instead. The following macro assumes you meant Column L.

Okay, here is a macro that should do what you want without employing any loops...

Sub CheckColKandL()
Dim K As Range, L As Range
On Error Resume Next
Set K = Range("K4:K" & Rows.Count).SpecialCells(xlCellTypeConstants).Enti reRow
Set L = Range("L4:L" & Rows.Count).SpecialCells(xlCellTypeBlanks).EntireR ow
If Not K Is Nothing And Not L Is Nothing Then
If Not Application.Intersect(K, L) Is Nothing Then MsgBox "Please update the sheet"
End If
End Sub

--
Rick (MVP - Excel)


"tomjoe" wrote in message ...
I have a workbook with 2 sheets.
I am looking for a short procedure that detects if there, in sheet 2, is any
occupied cell in column K (K4 and down) with no data in the cell to the right
(column I). Then a message should pop up saying: "Please update the sheet".

Any suggestions?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Lookup VBA

I believe you should put an Exit For statement after your MsgBox statement,
otherwise you will pop up the MessageBox for each set of cells meeting the
If..Then test.

--
Rick (MVP - Excel)


"Gary''s Student" wrote in message
...
Sub FindMissing()
Dim k As Long, i As Long
With Sheets("Sheet2")
k = Cells(Rows.Count, "K").End(xlUp).Row
For i = 4 To k
If Cells(i, "K").Value < "" And Cells(i, "I").Value = "" Then
MsgBox "Please update the sheet"
End If
Next
End With
End Sub

--
Gary''s Student - gsnu201001


"tomjoe" wrote:

I have a workbook with 2 sheets.
I am looking for a short procedure that detects if there, in sheet 2, is
any
occupied cell in column K (K4 and down) with no data in the cell to the
right
(column I). Then a message should pop up saying: "Please update the
sheet".

Any suggestions?


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Lookup VBA

I believe you should put an Exit For statement after your MsgBox statement,
otherwise you will pop up the MessageBox for each set of cells meeting the
If..Then test.

--
Rick (MVP - Excel)


"JLGWhiz" wrote in message
...
Sub isitthere()
Dim lr As Long, rng As Range
lr = ActiveSheet.Cells(Rows.Count, "K").End(slUp).Row
rng = ActiveSheet.Range("K4:K" & lr)
For Each c In rng
If c.Value "" And c.Offset(0, 1) = "" Then
MsgBox "Please Update the Sheet"
End If
Next
End Sub


"tomjoe" wrote in message
...
I have a workbook with 2 sheets.
I am looking for a short procedure that detects if there, in sheet 2, is
any
occupied cell in column K (K4 and down) with no data in the cell to the
right
(column I). Then a message should pop up saying: "Please update the
sheet".

Any suggestions?






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default Lookup VBA

Yep, you are correct, Rick. Actually, there is a lot more code that could
be added to make the process fully effective. I suppose the OP will figure
that out as they progress.


"Rick Rothstein" wrote in message
...
I believe you should put an Exit For statement after your MsgBox statement,
otherwise you will pop up the MessageBox for each set of cells meeting the
If..Then test.

--
Rick (MVP - Excel)


"JLGWhiz" wrote in message
...
Sub isitthere()
Dim lr As Long, rng As Range
lr = ActiveSheet.Cells(Rows.Count, "K").End(slUp).Row
rng = ActiveSheet.Range("K4:K" & lr)
For Each c In rng
If c.Value "" And c.Offset(0, 1) = "" Then
MsgBox "Please Update the Sheet"
End If
Next
End Sub


"tomjoe" wrote in message
...
I have a workbook with 2 sheets.
I am looking for a short procedure that detects if there, in sheet 2, is
any
occupied cell in column K (K4 and down) with no data in the cell to the
right
(column I). Then a message should pop up saying: "Please update the
sheet".

Any suggestions?






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
lookup help. lookup result based on data in 2 columns lcc Excel Worksheet Functions 3 April 6th 10 01:20 PM
LOOKUP FUNCTION? (LOOKUP VALUE BEING A TIME RENERATED FROM A FORMU JCC Excel Discussion (Misc queries) 5 June 26th 09 09:15 PM
Matrix lookup/mulitple criteria lookup MarkFranklin Excel Discussion (Misc queries) 3 March 31st 08 10:15 AM
Join 2 Lists - Lookup value in 1 list & use result in 2nd lookup JBush Excel Worksheet Functions 3 January 3rd 07 11:14 PM
Pivot table doing a lookup without using the lookup function? NGASGELI Excel Discussion (Misc queries) 0 August 2nd 05 05:08 AM


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