Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Find 1st empty cell within each row

Hi all, I have a worksheet filled with students information (ID,name,
nationality.. etc.) and we are requested to give a print outs of
students with any information missing from his record, so my plan is
to create a macro that do the following:
- loop throgh every row until it reachs the end of the worksheet
- in each loop it will check if any of the cells is empty
- if one of the cells is empty it will copy this row to a new sheet
and then start at the beginning of the next row then continue the loop
- if none of the cells is empty (no information is missing) then go to
the beginning of the next row then continue the loop.

this is what I came up with:

Dim tmp As Integer
Do Until IsEmpty(ActiveCell)
For I = 1 To 11 ' 11 columns in each row that I have to check
Do While bolFlagged = True
If ActiveCell.Value = Empty Then
sheet2nextcell ' a function that copies the
current row to another sheet
bolFlagged = False ' I used this variable for
students not to dublicate
GoTo ExitLoop
End If
ActiveCell.Offset(0, 1).Select
Loop
ExitLoop:
Next I
Cells(ActiveWindow.RangeSelection.Row, 1).Select 'first cell
in current row
ActiveCell.Offset(1, 0).Select

as you may see this code isn't correct at all because I am no
programmer I can't figure out what I am doing wrong, so any input
would be appreciated.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Find 1st empty cell within each row

One way:

Const cnCOLS As Long = 11

Dim rCell As Range
Dim rDest As Range

With Worksheets("Destination")
Set rDest = .Cells(.Rows.Count, 1).End(xlUp).Offset(1, 0)
End With
With Worksheets("Source")
For Each rCell In .Range(.Cells(2, 1), _
.Cells(.Rows.Count, 1).End(xlUp))
With rCell.Resize(1, cnCOLS)
If Application.CountA(.Cells) < cnCOLS Then
.Copy Destination:=rDest
Set rDest = rDest.Offset(1, 0)
End If
End With
Next rCell
End With


In article .com,
wrote:

Hi all, I have a worksheet filled with students information (ID,name,
nationality.. etc.) and we are requested to give a print outs of
students with any information missing from his record, so my plan is
to create a macro that do the following:
- loop throgh every row until it reachs the end of the worksheet
- in each loop it will check if any of the cells is empty
- if one of the cells is empty it will copy this row to a new sheet
and then start at the beginning of the next row then continue the loop
- if none of the cells is empty (no information is missing) then go to
the beginning of the next row then continue the loop.

this is what I came up with:

Dim tmp As Integer
Do Until IsEmpty(ActiveCell)
For I = 1 To 11 ' 11 columns in each row that I have to check
Do While bolFlagged = True
If ActiveCell.Value = Empty Then
sheet2nextcell ' a function that copies the
current row to another sheet
bolFlagged = False ' I used this variable for
students not to dublicate
GoTo ExitLoop
End If
ActiveCell.Offset(0, 1).Select
Loop
ExitLoop:
Next I
Cells(ActiveWindow.RangeSelection.Row, 1).Select 'first cell
in current row
ActiveCell.Offset(1, 0).Select

as you may see this code isn't correct at all because I am no
programmer I can't figure out what I am doing wrong, so any input
would be appreciated.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Find 1st empty cell within each row

On Apr 23, 2:32 pm, JE McGimpsey wrote:
One way:

Const cnCOLS As Long = 11

Dim rCell As Range
Dim rDest As Range

With Worksheets("Destination")
Set rDest = .Cells(.Rows.Count, 1).End(xlUp).Offset(1, 0)
End With
With Worksheets("Source")
For Each rCell In .Range(.Cells(2, 1), _
.Cells(.Rows.Count, 1).End(xlUp))
With rCell.Resize(1, cnCOLS)
If Application.CountA(.Cells) < cnCOLS Then
.Copy Destination:=rDest
Set rDest = rDest.Offset(1, 0)
End If
End With
Next rCell
End With

In article .com,



wrote:
Hi all, I have a worksheet filled with students information (ID,name,
nationality.. etc.) and we are requested to give a print outs of
students with any information missing from his record, so my plan is
to create a macro that do the following:
- loop throgh every row until it reachs the end of the worksheet
- in each loop it will check if any of the cells is empty
- if one of the cells is empty it will copy this row to a new sheet
and then start at the beginning of the next row then continue the loop
- if none of the cells is empty (no information is missing) then go to
the beginning of the next row then continue the loop.


this is what I came up with:


Dim tmp As Integer
Do Until IsEmpty(ActiveCell)
For I = 1 To 11 ' 11 columns in each row that I have to check
Do While bolFlagged = True
If ActiveCell.Value = Empty Then
sheet2nextcell ' a function that copies the
current row to another sheet
bolFlagged = False ' I used this variable for
students not to dublicate
GoTo ExitLoop
End If
ActiveCell.Offset(0, 1).Select
Loop
ExitLoop:
Next I
Cells(ActiveWindow.RangeSelection.Row, 1).Select 'first cell
in current row
ActiveCell.Offset(1, 0).Select


as you may see this code isn't correct at all because I am no
programmer I can't figure out what I am doing wrong, so any input
would be appreciated.- Hide quoted text -


- Show quoted text -


Thank you JE McGimpsey for your answer it worked beautifully.

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
find last none empty cell kevcar40 Excel Discussion (Misc queries) 3 March 1st 06 11:59 AM
To find empty cell Asu Excel Programming 3 December 3rd 05 05:44 PM
Please help find the next empty cell pcarsquared Excel Programming 5 May 17th 04 10:23 PM
Find 1st Empty Cell: How to? Chris Excel Programming 4 December 2nd 03 09:41 PM
Find Empty Cell Wally Steadman[_3_] Excel Programming 3 November 23rd 03 10:50 PM


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